^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) #!/usr/bin/perl -w
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) # SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) # Copyright 2010 - Steven Rostedt <srostedt@redhat.com>, Red Hat Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) use strict;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) use IPC::Open2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) use File::Path qw(mkpath);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) use File::Copy qw(cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) use FileHandle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) use FindBin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) use IO::Handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) my $VERSION = "0.2";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) $| = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) my %opt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) my %repeat_tests;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) my %repeats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) my %evals;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #default opts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) my %default = (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) "MAILER" => "sendmail", # default mailer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) "EMAIL_ON_ERROR" => 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) "EMAIL_WHEN_FINISHED" => 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) "EMAIL_WHEN_CANCELED" => 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) "EMAIL_WHEN_STARTED" => 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) "NUM_TESTS" => 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) "TEST_TYPE" => "build",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) "BUILD_TYPE" => "oldconfig",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) "MAKE_CMD" => "make",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) "CLOSE_CONSOLE_SIGNAL" => "INT",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) "TIMEOUT" => 120,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) "TMP_DIR" => "/tmp/ktest/\${MACHINE}",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) "SLEEP_TIME" => 60, # sleep time between tests
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) "BUILD_NOCLEAN" => 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) "REBOOT_ON_ERROR" => 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) "POWEROFF_ON_ERROR" => 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) "REBOOT_ON_SUCCESS" => 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) "POWEROFF_ON_SUCCESS" => 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) "BUILD_OPTIONS" => "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) "BISECT_SLEEP_TIME" => 60, # sleep time between bisects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) "PATCHCHECK_SLEEP_TIME" => 60, # sleep time between patch checks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) "CLEAR_LOG" => 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) "BISECT_MANUAL" => 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) "BISECT_SKIP" => 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) "BISECT_TRIES" => 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) "MIN_CONFIG_TYPE" => "boot",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) "SUCCESS_LINE" => "login:",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) "DETECT_TRIPLE_FAULT" => 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) "NO_INSTALL" => 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) "BOOTED_TIMEOUT" => 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) "DIE_ON_FAILURE" => 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) "SSH_EXEC" => "ssh \$SSH_USER\@\$MACHINE \$SSH_COMMAND",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) "SCP_TO_TARGET" => "scp \$SRC_FILE \$SSH_USER\@\$MACHINE:\$DST_FILE",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) "SCP_TO_TARGET_INSTALL" => "\${SCP_TO_TARGET}",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) "REBOOT" => "ssh \$SSH_USER\@\$MACHINE reboot",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) "REBOOT_RETURN_CODE" => 255,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) "STOP_AFTER_SUCCESS" => 10,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) "STOP_AFTER_FAILURE" => 60,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) "STOP_TEST_AFTER" => 600,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) "MAX_MONITOR_WAIT" => 1800,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) "GRUB_REBOOT" => "grub2-reboot",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) "GRUB_BLS_GET" => "grubby --info=ALL",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) "SYSLINUX" => "extlinux",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) "SYSLINUX_PATH" => "/boot/extlinux",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) "CONNECT_TIMEOUT" => 25,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) # required, and we will ask users if they don't have them but we keep the default
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) # value something that is common.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) "REBOOT_TYPE" => "grub",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) "LOCALVERSION" => "-test",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) "SSH_USER" => "root",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) "BUILD_TARGET" => "arch/x86/boot/bzImage",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) "TARGET_IMAGE" => "/boot/vmlinuz-test",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) "LOG_FILE" => undef,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) "IGNORE_UNUSED" => 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) my $test_log_start = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) my $ktest_config = "ktest.conf";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) my $version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) my $have_version = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) my $machine;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) my $last_machine;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) my $ssh_user;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) my $tmpdir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) my $builddir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) my $outputdir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) my $output_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) my $test_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) my $build_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) my $build_options;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) my $final_post_ktest;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) my $pre_ktest;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) my $post_ktest;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) my $pre_test;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) my $pre_test_die;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) my $post_test;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) my $pre_build;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) my $post_build;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) my $pre_build_die;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) my $post_build_die;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) my $reboot_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) my $reboot_script;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) my $power_cycle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) my $reboot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) my $reboot_return_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) my $reboot_on_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) my $switch_to_good;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) my $switch_to_test;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) my $poweroff_on_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) my $reboot_on_success;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) my $die_on_failure;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) my $powercycle_after_reboot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) my $poweroff_after_halt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) my $max_monitor_wait;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) my $ssh_exec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) my $scp_to_target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) my $scp_to_target_install;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) my $power_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) my $grub_menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) my $last_grub_menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) my $grub_file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) my $grub_number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) my $grub_reboot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) my $grub_bls_get;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) my $syslinux;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) my $syslinux_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) my $syslinux_label;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) my $target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) my $make;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) my $pre_install;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) my $post_install;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) my $no_install;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) my $noclean;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) my $minconfig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) my $start_minconfig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) my $start_minconfig_defined;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) my $output_minconfig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) my $minconfig_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) my $use_output_minconfig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) my $warnings_file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) my $ignore_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) my $ignore_errors;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) my $addconfig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) my $in_bisect = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) my $bisect_bad_commit = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) my $reverse_bisect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) my $bisect_manual;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) my $bisect_skip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) my $bisect_tries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) my $config_bisect_good;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) my $bisect_ret_good;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) my $bisect_ret_bad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) my $bisect_ret_skip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) my $bisect_ret_abort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) my $bisect_ret_default;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) my $in_patchcheck = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) my $run_test;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) my $buildlog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) my $testlog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) my $dmesg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) my $monitor_fp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) my $monitor_pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) my $monitor_cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) my $sleep_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) my $bisect_sleep_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) my $patchcheck_sleep_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) my $ignore_warnings;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) my $store_failures;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) my $store_successes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) my $test_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) my $timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) my $connect_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) my $config_bisect_exec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) my $booted_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) my $detect_triplefault;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) my $console;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) my $close_console_signal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) my $reboot_success_line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) my $success_line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) my $stop_after_success;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) my $stop_after_failure;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) my $stop_test_after;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) my $build_target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) my $target_image;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) my $checkout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) my $localversion;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) my $iteration = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) my $successes = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) my $stty_orig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) my $run_command_status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) my $bisect_good;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) my $bisect_bad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) my $bisect_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) my $bisect_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) my $bisect_replay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) my $bisect_files;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) my $bisect_reverse;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) my $bisect_check;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) my $config_bisect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) my $config_bisect_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) my $config_bisect_check;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) my $patchcheck_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) my $patchcheck_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) my $patchcheck_cherry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) my $patchcheck_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) my $build_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) my $install_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) my $reboot_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) my $test_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) my $pwd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) my $dirname = $FindBin::Bin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) my $mailto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) my $mailer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) my $mail_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) my $mail_max_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) my $mail_command;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) my $email_on_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) my $email_when_finished;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) my $email_when_started;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) my $email_when_canceled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) my $script_start_time = localtime();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) # set when a test is something other that just building or install
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) # which would require more options.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) my $buildonly = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) # tell build not to worry about warnings, even when WARNINGS_FILE is set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) my $warnings_ok = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) # set when creating a new config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) my $newconfig = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) my %entered_configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) my %config_help;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) my %variable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) # force_config is the list of configs that we force enabled (or disabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) # in a .config file. The MIN_CONFIG and ADD_CONFIG configs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) my %force_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) # do not force reboots on config problems
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) my $no_reboot = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) # reboot on success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) my $reboot_success = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) my %option_map = (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) "MAILTO" => \$mailto,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) "MAILER" => \$mailer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) "MAIL_PATH" => \$mail_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) "MAIL_MAX_SIZE" => \$mail_max_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) "MAIL_COMMAND" => \$mail_command,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) "EMAIL_ON_ERROR" => \$email_on_error,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) "EMAIL_WHEN_FINISHED" => \$email_when_finished,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) "EMAIL_WHEN_STARTED" => \$email_when_started,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) "EMAIL_WHEN_CANCELED" => \$email_when_canceled,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) "MACHINE" => \$machine,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) "SSH_USER" => \$ssh_user,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) "TMP_DIR" => \$tmpdir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) "OUTPUT_DIR" => \$outputdir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) "BUILD_DIR" => \$builddir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) "TEST_TYPE" => \$test_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) "PRE_KTEST" => \$pre_ktest,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) "POST_KTEST" => \$post_ktest,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) "PRE_TEST" => \$pre_test,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) "PRE_TEST_DIE" => \$pre_test_die,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) "POST_TEST" => \$post_test,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) "BUILD_TYPE" => \$build_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) "BUILD_OPTIONS" => \$build_options,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) "PRE_BUILD" => \$pre_build,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) "POST_BUILD" => \$post_build,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) "PRE_BUILD_DIE" => \$pre_build_die,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) "POST_BUILD_DIE" => \$post_build_die,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) "POWER_CYCLE" => \$power_cycle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) "REBOOT" => \$reboot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) "REBOOT_RETURN_CODE" => \$reboot_return_code,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) "BUILD_NOCLEAN" => \$noclean,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) "MIN_CONFIG" => \$minconfig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) "OUTPUT_MIN_CONFIG" => \$output_minconfig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) "START_MIN_CONFIG" => \$start_minconfig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) "MIN_CONFIG_TYPE" => \$minconfig_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) "USE_OUTPUT_MIN_CONFIG" => \$use_output_minconfig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) "WARNINGS_FILE" => \$warnings_file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) "IGNORE_CONFIG" => \$ignore_config,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) "TEST" => \$run_test,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) "ADD_CONFIG" => \$addconfig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) "REBOOT_TYPE" => \$reboot_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) "GRUB_MENU" => \$grub_menu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) "GRUB_FILE" => \$grub_file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) "GRUB_REBOOT" => \$grub_reboot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) "GRUB_BLS_GET" => \$grub_bls_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) "SYSLINUX" => \$syslinux,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) "SYSLINUX_PATH" => \$syslinux_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) "SYSLINUX_LABEL" => \$syslinux_label,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) "PRE_INSTALL" => \$pre_install,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) "POST_INSTALL" => \$post_install,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) "NO_INSTALL" => \$no_install,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) "REBOOT_SCRIPT" => \$reboot_script,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) "REBOOT_ON_ERROR" => \$reboot_on_error,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) "SWITCH_TO_GOOD" => \$switch_to_good,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) "SWITCH_TO_TEST" => \$switch_to_test,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) "POWEROFF_ON_ERROR" => \$poweroff_on_error,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) "REBOOT_ON_SUCCESS" => \$reboot_on_success,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) "DIE_ON_FAILURE" => \$die_on_failure,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) "POWER_OFF" => \$power_off,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) "POWERCYCLE_AFTER_REBOOT" => \$powercycle_after_reboot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) "POWEROFF_AFTER_HALT" => \$poweroff_after_halt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) "MAX_MONITOR_WAIT" => \$max_monitor_wait,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) "SLEEP_TIME" => \$sleep_time,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) "BISECT_SLEEP_TIME" => \$bisect_sleep_time,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) "PATCHCHECK_SLEEP_TIME" => \$patchcheck_sleep_time,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) "IGNORE_WARNINGS" => \$ignore_warnings,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) "IGNORE_ERRORS" => \$ignore_errors,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) "BISECT_MANUAL" => \$bisect_manual,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) "BISECT_SKIP" => \$bisect_skip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) "BISECT_TRIES" => \$bisect_tries,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) "CONFIG_BISECT_GOOD" => \$config_bisect_good,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) "BISECT_RET_GOOD" => \$bisect_ret_good,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) "BISECT_RET_BAD" => \$bisect_ret_bad,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) "BISECT_RET_SKIP" => \$bisect_ret_skip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) "BISECT_RET_ABORT" => \$bisect_ret_abort,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) "BISECT_RET_DEFAULT" => \$bisect_ret_default,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) "STORE_FAILURES" => \$store_failures,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) "STORE_SUCCESSES" => \$store_successes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) "TEST_NAME" => \$test_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) "TIMEOUT" => \$timeout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) "CONNECT_TIMEOUT" => \$connect_timeout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) "CONFIG_BISECT_EXEC" => \$config_bisect_exec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) "BOOTED_TIMEOUT" => \$booted_timeout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) "CONSOLE" => \$console,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) "CLOSE_CONSOLE_SIGNAL" => \$close_console_signal,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) "DETECT_TRIPLE_FAULT" => \$detect_triplefault,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) "SUCCESS_LINE" => \$success_line,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) "REBOOT_SUCCESS_LINE" => \$reboot_success_line,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) "STOP_AFTER_SUCCESS" => \$stop_after_success,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) "STOP_AFTER_FAILURE" => \$stop_after_failure,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) "STOP_TEST_AFTER" => \$stop_test_after,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) "BUILD_TARGET" => \$build_target,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) "SSH_EXEC" => \$ssh_exec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) "SCP_TO_TARGET" => \$scp_to_target,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) "SCP_TO_TARGET_INSTALL" => \$scp_to_target_install,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) "CHECKOUT" => \$checkout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) "TARGET_IMAGE" => \$target_image,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) "LOCALVERSION" => \$localversion,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) "BISECT_GOOD" => \$bisect_good,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) "BISECT_BAD" => \$bisect_bad,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) "BISECT_TYPE" => \$bisect_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) "BISECT_START" => \$bisect_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) "BISECT_REPLAY" => \$bisect_replay,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) "BISECT_FILES" => \$bisect_files,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) "BISECT_REVERSE" => \$bisect_reverse,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) "BISECT_CHECK" => \$bisect_check,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) "CONFIG_BISECT" => \$config_bisect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) "CONFIG_BISECT_TYPE" => \$config_bisect_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) "CONFIG_BISECT_CHECK" => \$config_bisect_check,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) "PATCHCHECK_TYPE" => \$patchcheck_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) "PATCHCHECK_START" => \$patchcheck_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) "PATCHCHECK_CHERRY" => \$patchcheck_cherry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) "PATCHCHECK_END" => \$patchcheck_end,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) # Options may be used by other options, record them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) my %used_options;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) # default variables that can be used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) chomp ($variable{"PWD"} = `pwd`);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) $pwd = $variable{"PWD"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) $config_help{"MACHINE"} = << "EOF"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) The machine hostname that you will test.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) For build only tests, it is still needed to differentiate log files.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) EOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) $config_help{"SSH_USER"} = << "EOF"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) The box is expected to have ssh on normal bootup, provide the user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) (most likely root, since you need privileged operations)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) EOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) $config_help{"BUILD_DIR"} = << "EOF"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) The directory that contains the Linux source code (full path).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) You can use \${PWD} that will be the path where ktest.pl is run, or use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) \${THIS_DIR} which is assigned \${PWD} but may be changed later.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) EOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) $config_help{"OUTPUT_DIR"} = << "EOF"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) The directory that the objects will be built (full path).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) (can not be same as BUILD_DIR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) You can use \${PWD} that will be the path where ktest.pl is run, or use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) \${THIS_DIR} which is assigned \${PWD} but may be changed later.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) EOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) $config_help{"BUILD_TARGET"} = << "EOF"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) The location of the compiled file to copy to the target.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) (relative to OUTPUT_DIR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) EOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) $config_help{"BUILD_OPTIONS"} = << "EOF"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) Options to add to \"make\" when building.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) i.e. -j20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) EOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) $config_help{"TARGET_IMAGE"} = << "EOF"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) The place to put your image on the test machine.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) EOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) $config_help{"POWER_CYCLE"} = << "EOF"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) A script or command to reboot the box.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) Here is a digital loggers power switch example
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) POWER_CYCLE = wget --no-proxy -O /dev/null -q --auth-no-challenge 'http://admin:admin\@power/outlet?5=CCL'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) Here is an example to reboot a virtual box on the current host
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) with the name "Guest".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) POWER_CYCLE = virsh destroy Guest; sleep 5; virsh start Guest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) EOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) $config_help{"CONSOLE"} = << "EOF"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) The script or command that reads the console
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) If you use ttywatch server, something like the following would work.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) CONSOLE = nc -d localhost 3001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) For a virtual machine with guest name "Guest".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) CONSOLE = virsh console Guest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) EOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) $config_help{"LOCALVERSION"} = << "EOF"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) Required version ending to differentiate the test
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) from other linux builds on the system.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) EOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) $config_help{"REBOOT_TYPE"} = << "EOF"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) Way to reboot the box to the test kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) Only valid options so far are "grub", "grub2", "grub2bls", "syslinux", and "script".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) If you specify grub, it will assume grub version 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) and will search in /boot/grub/menu.lst for the title \$GRUB_MENU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) and select that target to reboot to the kernel. If this is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) your setup, then specify "script" and have a command or script
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) specified in REBOOT_SCRIPT to boot to the target.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) The entry in /boot/grub/menu.lst must be entered in manually.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) The test will not modify that file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) If you specify grub2, then you also need to specify both \$GRUB_MENU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) and \$GRUB_FILE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) If you specify grub2bls, then you also need to specify \$GRUB_MENU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) If you specify syslinux, then you may use SYSLINUX to define the syslinux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) command (defaults to extlinux), and SYSLINUX_PATH to specify the path to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) the syslinux install (defaults to /boot/extlinux). But you have to specify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) SYSLINUX_LABEL to define the label to boot to for the test kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) EOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) $config_help{"GRUB_MENU"} = << "EOF"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) The grub title name for the test kernel to boot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) (Only mandatory if REBOOT_TYPE = grub or grub2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) Note, ktest.pl will not update the grub menu.lst, you need to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) manually add an option for the test. ktest.pl will search
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) the grub menu.lst for this option to find what kernel to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) reboot into.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) For example, if in the /boot/grub/menu.lst the test kernel title has:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) title Test Kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) kernel vmlinuz-test
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) GRUB_MENU = Test Kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) For grub2, a search of \$GRUB_FILE is performed for the lines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) that begin with "menuentry". It will not detect submenus. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) menu must be a non-nested menu. Add the quotes used in the menu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) to guarantee your selection, as the first menuentry with the content
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) of \$GRUB_MENU that is found will be used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) For grub2bls, \$GRUB_MENU is searched on the result of \$GRUB_BLS_GET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) command for the lines that begin with "title".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) EOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) $config_help{"GRUB_FILE"} = << "EOF"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) If grub2 is used, the full path for the grub.cfg file is placed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) here. Use something like /boot/grub2/grub.cfg to search.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) EOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) $config_help{"SYSLINUX_LABEL"} = << "EOF"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) If syslinux is used, the label that boots the target kernel must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) be specified with SYSLINUX_LABEL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) EOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) $config_help{"REBOOT_SCRIPT"} = << "EOF"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) A script to reboot the target into the test kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) (Only mandatory if REBOOT_TYPE = script)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) EOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) sub _logit {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) if (defined($opt{"LOG_FILE"})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) print LOG @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) sub logit {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) if (defined($opt{"LOG_FILE"})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) _logit @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) print @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) sub doprint {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) print @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) _logit @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) sub read_prompt {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) my ($cancel, $prompt) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) my $ans;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) for (;;) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) if ($cancel) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) print "$prompt [y/n/C] ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) print "$prompt [Y/n] ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) $ans = <STDIN>;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) chomp $ans;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) if ($ans =~ /^\s*$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) if ($cancel) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) $ans = "c";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) $ans = "y";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) last if ($ans =~ /^y$/i || $ans =~ /^n$/i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) if ($cancel) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) last if ($ans =~ /^c$/i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) print "Please answer either 'y', 'n' or 'c'.\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) print "Please answer either 'y' or 'n'.\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) if ($ans =~ /^c/i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) if ($ans !~ /^y$/i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) sub read_yn {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) my ($prompt) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) return read_prompt 0, $prompt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) sub read_ync {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) my ($prompt) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) return read_prompt 1, $prompt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) sub get_mandatory_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) my ($config) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) my $ans;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) return if (defined($opt{$config}));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) if (defined($config_help{$config})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) print "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) print $config_help{$config};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) for (;;) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) print "$config = ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) if (defined($default{$config}) && length($default{$config})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) print "\[$default{$config}\] ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) $ans = <STDIN>;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) $ans =~ s/^\s*(.*\S)\s*$/$1/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) if ($ans =~ /^\s*$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) if ($default{$config}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) $ans = $default{$config};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) print "Your answer can not be blank\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) $entered_configs{$config} = ${ans};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) sub show_time {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) my ($time) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) my $hours = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) my $minutes = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) if ($time > 3600) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) $hours = int($time / 3600);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) $time -= $hours * 3600;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) if ($time > 60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) $minutes = int($time / 60);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) $time -= $minutes * 60;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) if ($hours > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) doprint "$hours hour";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) doprint "s" if ($hours > 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) doprint " ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) if ($minutes > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) doprint "$minutes minute";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) doprint "s" if ($minutes > 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) doprint " ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) doprint "$time second";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) doprint "s" if ($time != 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) sub print_times {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) doprint "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) if ($build_time) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) doprint "Build time: ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) show_time($build_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) doprint "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) if ($install_time) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) doprint "Install time: ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) show_time($install_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) doprint "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) if ($reboot_time) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) doprint "Reboot time: ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) show_time($reboot_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) doprint "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) if ($test_time) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) doprint "Test time: ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) show_time($test_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) doprint "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) # reset for iterations like bisect
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) $build_time = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) $install_time = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) $reboot_time = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) $test_time = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) sub get_mandatory_configs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) get_mandatory_config("MACHINE");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) get_mandatory_config("BUILD_DIR");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) get_mandatory_config("OUTPUT_DIR");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) if ($newconfig) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) get_mandatory_config("BUILD_OPTIONS");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) # options required for other than just building a kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) if (!$buildonly) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) get_mandatory_config("POWER_CYCLE");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) get_mandatory_config("CONSOLE");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) # options required for install and more
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) if ($buildonly != 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) get_mandatory_config("SSH_USER");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) get_mandatory_config("BUILD_TARGET");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) get_mandatory_config("TARGET_IMAGE");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) get_mandatory_config("LOCALVERSION");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) return if ($buildonly);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) my $rtype = $opt{"REBOOT_TYPE"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) if (!defined($rtype)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) if (!defined($opt{"GRUB_MENU"})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) get_mandatory_config("REBOOT_TYPE");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) $rtype = $entered_configs{"REBOOT_TYPE"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) $rtype = "grub";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) if (($rtype eq "grub") or ($rtype eq "grub2bls")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) get_mandatory_config("GRUB_MENU");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) if ($rtype eq "grub2") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) get_mandatory_config("GRUB_MENU");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) get_mandatory_config("GRUB_FILE");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) if ($rtype eq "syslinux") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) get_mandatory_config("SYSLINUX_LABEL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) sub process_variables {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) my ($value, $remove_undef) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) my $retval = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) # We want to check for '\', and it is just easier
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) # to check the previous characet of '$' and not need
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) # to worry if '$' is the first character. By adding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) # a space to $value, we can just check [^\\]\$ and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) # it will still work.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) $value = " $value";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) while ($value =~ /(.*?[^\\])\$\{(.*?)\}(.*)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) my $begin = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) my $var = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) my $end = $3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) # append beginning of value to retval
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) $retval = "$retval$begin";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) if (defined($variable{$var})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) $retval = "$retval$variable{$var}";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) } elsif (defined($remove_undef) && $remove_undef) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) # for if statements, any variable that is not defined,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) # we simple convert to 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) $retval = "${retval}0";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) # put back the origin piece.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) $retval = "$retval\$\{$var\}";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) # This could be an option that is used later, save
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) # it so we don't warn if this option is not one of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) # ktests options.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) $used_options{$var} = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) $value = $end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) $retval = "$retval$value";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) # remove the space added in the beginning
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) $retval =~ s/ //;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) return "$retval"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) sub set_value {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) my ($lvalue, $rvalue, $override, $overrides, $name) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) my $prvalue = process_variables($rvalue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) if ($lvalue =~ /^(TEST|BISECT|CONFIG_BISECT)_TYPE(\[.*\])?$/ &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) $prvalue !~ /^(config_|)bisect$/ &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) $prvalue !~ /^build$/ &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) $buildonly) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) # Note if a test is something other than build, then we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) # will need other mandatory options.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) if ($prvalue ne "install") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) $buildonly = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) # install still limits some mandatory options.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) $buildonly = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) if (defined($opt{$lvalue})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) if (!$override || defined(${$overrides}{$lvalue})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) my $extra = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) if ($override) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) $extra = "In the same override section!\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) die "$name: $.: Option $lvalue defined more than once!\n$extra";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) ${$overrides}{$lvalue} = $prvalue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) $opt{$lvalue} = $prvalue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) sub set_eval {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) my ($lvalue, $rvalue, $name) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) my $prvalue = process_variables($rvalue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) my $arr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) if (defined($evals{$lvalue})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) $arr = $evals{$lvalue};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) $arr = [];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) $evals{$lvalue} = $arr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) push @{$arr}, $rvalue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) sub set_variable {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) my ($lvalue, $rvalue) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) if ($rvalue =~ /^\s*$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) delete $variable{$lvalue};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) $rvalue = process_variables($rvalue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) $variable{$lvalue} = $rvalue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) sub process_compare {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) my ($lval, $cmp, $rval) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) # remove whitespace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) $lval =~ s/^\s*//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) $lval =~ s/\s*$//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) $rval =~ s/^\s*//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) $rval =~ s/\s*$//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) if ($cmp eq "==") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) return $lval eq $rval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) } elsif ($cmp eq "!=") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) return $lval ne $rval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) } elsif ($cmp eq "=~") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) return $lval =~ m/$rval/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) } elsif ($cmp eq "!~") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) return $lval !~ m/$rval/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) my $statement = "$lval $cmp $rval";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) my $ret = eval $statement;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) # $@ stores error of eval
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) if ($@) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) return $ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) sub value_defined {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) my ($val) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) return defined($variable{$2}) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) defined($opt{$2});
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) my $d = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) sub process_expression {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) my ($name, $val) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) my $c = $d++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) while ($val =~ s/\(([^\(]*?)\)/\&\&\&\&VAL\&\&\&\&/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) my $express = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) if (process_expression($name, $express)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) $val =~ s/\&\&\&\&VAL\&\&\&\&/ 1 /;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) $val =~ s/\&\&\&\&VAL\&\&\&\&/ 0 /;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) $d--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) my $OR = "\\|\\|";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) my $AND = "\\&\\&";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) while ($val =~ s/^(.*?)($OR|$AND)//) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) my $express = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) my $op = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) if (process_expression($name, $express)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) if ($op eq "||") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) if ($op eq "&&") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) if ($val =~ /(.*)(==|\!=|>=|<=|>|<|=~|\!~)(.*)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) my $ret = process_compare($1, $2, $3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) if ($ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) die "$name: $.: Unable to process comparison\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) return $ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) if ($val =~ /^\s*(NOT\s*)?DEFINED\s+(\S+)\s*$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) if (defined $1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) return !value_defined($2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) return value_defined($2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) if ($val =~ s/^\s*NOT\s+(.*)//) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) my $express = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) my $ret = process_expression($name, $express);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) return !$ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) if ($val =~ /^\s*0\s*$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) } elsif ($val =~ /^\s*\d+\s*$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) die ("$name: $.: Undefined content $val in if statement\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) sub process_if {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) my ($name, $value) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) # Convert variables and replace undefined ones with 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) my $val = process_variables($value, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) my $ret = process_expression $name, $val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) return $ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) sub __read_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) my ($config, $current_test_num) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) my $in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) open($in, $config) || die "can't read file $config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) my $name = $config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) $name =~ s,.*/(.*),$1,;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) my $test_num = $$current_test_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) my $default = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) my $repeat = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) my $num_tests_set = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) my $skip = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) my $rest;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) my $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) my $test_case = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) my $if = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) my $if_set = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) my $override = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) my %overrides;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) while (<$in>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) # ignore blank lines and comments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) next if (/^\s*$/ || /\s*\#/);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) if (/^\s*(TEST_START|DEFAULTS)\b(.*)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) my $type = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) $rest = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) $line = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) my $old_test_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) my $old_repeat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) $override = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) if ($type eq "TEST_START") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) if ($num_tests_set) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) die "$name: $.: Can not specify both NUM_TESTS and TEST_START\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) $old_test_num = $test_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) $old_repeat = $repeat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) $test_num += $repeat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) $default = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) $repeat = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) $default = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) # If SKIP is anywhere in the line, the command will be skipped
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) if ($rest =~ s/\s+SKIP\b//) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) $skip = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) $test_case = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) $skip = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) if ($rest =~ s/\sELSE\b//) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) if (!$if) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) die "$name: $.: ELSE found with out matching IF section\n$_";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) $if = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) if ($if_set) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) $skip = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) $skip = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) if ($rest =~ s/\sIF\s+(.*)//) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) if (process_if($name, $1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) $if_set = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) $skip = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) $if = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) $if = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) $if_set = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) if (!$skip) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) if ($type eq "TEST_START") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) if ($rest =~ s/\s+ITERATE\s+(\d+)//) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) $repeat = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) $repeat_tests{"$test_num"} = $repeat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) } elsif ($rest =~ s/\sOVERRIDE\b//) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) # DEFAULT only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) $override = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) # Clear previous overrides
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) %overrides = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) if (!$skip && $rest !~ /^\s*$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) die "$name: $.: Garbage found after $type\n$_";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) if ($skip && $type eq "TEST_START") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) $test_num = $old_test_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) $repeat = $old_repeat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) } elsif (/^\s*ELSE\b(.*)$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) if (!$if) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) die "$name: $.: ELSE found with out matching IF section\n$_";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) $rest = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) if ($if_set) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) $skip = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) $rest = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) $skip = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) if ($rest =~ /\sIF\s+(.*)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) # May be a ELSE IF section.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) if (process_if($name, $1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) $if_set = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) $skip = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) $rest = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) $if = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) if ($rest !~ /^\s*$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) die "$name: $.: Garbage found after DEFAULTS\n$_";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) } elsif (/^\s*INCLUDE\s+(\S+)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) next if ($skip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) if (!$default) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) die "$name: $.: INCLUDE can only be done in default sections\n$_";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) my $file = process_variables($1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) if ($file !~ m,^/,) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) # check the path of the config file first
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) if ($config =~ m,(.*)/,) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) if (-f "$1/$file") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) $file = "$1/$file";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) if ( ! -r $file ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) die "$name: $.: Can't read file $file\n$_";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) if (__read_config($file, \$test_num)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) $test_case = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) } elsif (/^\s*([A-Z_\[\]\d]+)\s*=~\s*(.*?)\s*$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) next if ($skip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) my $lvalue = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) my $rvalue = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) if ($default || $lvalue =~ /\[\d+\]$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) set_eval($lvalue, $rvalue, $name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) my $val = "$lvalue\[$test_num\]";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) set_eval($val, $rvalue, $name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) } elsif (/^\s*([A-Z_\[\]\d]+)\s*=\s*(.*?)\s*$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) next if ($skip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) my $lvalue = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) my $rvalue = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) if (!$default &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) ($lvalue eq "NUM_TESTS" ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) $lvalue eq "LOG_FILE" ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) $lvalue eq "CLEAR_LOG")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) die "$name: $.: $lvalue must be set in DEFAULTS section\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) if ($lvalue eq "NUM_TESTS") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) if ($test_num) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) die "$name: $.: Can not specify both NUM_TESTS and TEST_START\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) if (!$default) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) die "$name: $.: NUM_TESTS must be set in default section\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) $num_tests_set = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) if ($default || $lvalue =~ /\[\d+\]$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) set_value($lvalue, $rvalue, $override, \%overrides, $name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) my $val = "$lvalue\[$test_num\]";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) set_value($val, $rvalue, $override, \%overrides, $name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) if ($repeat > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) $repeats{$val} = $repeat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) } elsif (/^\s*([A-Z_\[\]\d]+)\s*:=\s*(.*?)\s*$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) next if ($skip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) my $lvalue = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) my $rvalue = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) # process config variables.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) # Config variables are only active while reading the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) # config and can be defined anywhere. They also ignore
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) # TEST_START and DEFAULTS, but are skipped if they are in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) # on of these sections that have SKIP defined.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) # The save variable can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) # defined multiple times and the new one simply overrides
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) # the previous one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) set_variable($lvalue, $rvalue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) die "$name: $.: Garbage found in config\n$_";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) if ($test_num) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) $test_num += $repeat - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) $opt{"NUM_TESTS"} = $test_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) close($in);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) $$current_test_num = $test_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) return $test_case;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) sub get_test_case {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) print "What test case would you like to run?\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) print " (build, install or boot)\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) print " Other tests are available but require editing ktest.conf\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) print " (see tools/testing/ktest/sample.conf)\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) my $ans = <STDIN>;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) chomp $ans;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) $default{"TEST_TYPE"} = $ans;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) sub read_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) my ($config) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) my $test_case;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) my $test_num = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) $test_case = __read_config $config, \$test_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) # make sure we have all mandatory configs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) get_mandatory_configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) # was a test specified?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) if (!$test_case) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) print "No test case specified.\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) get_test_case;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) # set any defaults
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) foreach my $default (keys %default) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) if (!defined($opt{$default})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) $opt{$default} = $default{$default};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) if ($opt{"IGNORE_UNUSED"} == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) my %not_used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) # check if there are any stragglers (typos?)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) foreach my $option (keys %opt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) my $op = $option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) # remove per test labels.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) $op =~ s/\[.*\]//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) if (!exists($option_map{$op}) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) !exists($default{$op}) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) !exists($used_options{$op})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) $not_used{$op} = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) if (%not_used) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) my $s = "s are";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) $s = " is" if (keys %not_used == 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) print "The following option$s not used; could be a typo:\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) foreach my $option (keys %not_used) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) print "$option\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) print "Set IGNORE_UNUSED = 1 to have ktest ignore unused variables\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) if (!read_yn "Do you want to continue?") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) exit -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) sub __eval_option {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) my ($name, $option, $i) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) # Add space to evaluate the character before $
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) $option = " $option";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) my $retval = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) my $repeated = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) my $parent = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) foreach my $test (keys %repeat_tests) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) if ($i >= $test &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) $i < $test + $repeat_tests{$test}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) $repeated = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) $parent = $test;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) while ($option =~ /(.*?[^\\])\$\{(.*?)\}(.*)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) my $start = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) my $var = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) my $end = $3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) # Append beginning of line
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) $retval = "$retval$start";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) # If the iteration option OPT[$i] exists, then use that.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) # otherwise see if the default OPT (without [$i]) exists.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) my $o = "$var\[$i\]";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) my $parento = "$var\[$parent\]";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) # If a variable contains itself, use the default var
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) if (($var eq $name) && defined($opt{$var})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) $o = $opt{$var};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) $retval = "$retval$o";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) } elsif (defined($opt{$o})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) $o = $opt{$o};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) $retval = "$retval$o";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) } elsif ($repeated && defined($opt{$parento})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) $o = $opt{$parento};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) $retval = "$retval$o";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) } elsif (defined($opt{$var})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) $o = $opt{$var};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) $retval = "$retval$o";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) } elsif ($var eq "KERNEL_VERSION" && defined($make)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) # special option KERNEL_VERSION uses kernel version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) get_version();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) $retval = "$retval$version";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) $retval = "$retval\$\{$var\}";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) $option = $end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) $retval = "$retval$option";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) $retval =~ s/^ //;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) return $retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) sub process_evals {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) my ($name, $option, $i) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) my $option_name = "$name\[$i\]";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) my $ev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) my $old_option = $option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) if (defined($evals{$option_name})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) $ev = $evals{$option_name};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) } elsif (defined($evals{$name})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) $ev = $evals{$name};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) return $option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) for my $e (@{$ev}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) eval "\$option =~ $e";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) if ($option ne $old_option) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) doprint("$name changed from '$old_option' to '$option'\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) return $option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) sub eval_option {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) my ($name, $option, $i) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) my $prev = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) # Since an option can evaluate to another option,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) # keep iterating until we do not evaluate any more
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) # options.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) my $r = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) while ($prev ne $option) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) # Check for recursive evaluations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) # 100 deep should be more than enough.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) if ($r++ > 100) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) die "Over 100 evaluations occurred with $option\n" .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) "Check for recursive variables\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) $prev = $option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) $option = __eval_option($name, $option, $i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) $option = process_evals($name, $option, $i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) return $option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) sub run_command;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) sub start_monitor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) sub end_monitor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) sub wait_for_monitor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) sub reboot {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) my ($time) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) my $powercycle = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) # test if the machine can be connected to within a few seconds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) my $stat = run_ssh("echo check machine status", $connect_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) if (!$stat) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) doprint("power cycle\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) $powercycle = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) if ($powercycle) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) run_command "$power_cycle";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) start_monitor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) # flush out current monitor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) # May contain the reboot success line
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) wait_for_monitor 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) # Make sure everything has been written to disk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) run_ssh("sync", 10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) if (defined($time)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) start_monitor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) # flush out current monitor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) # May contain the reboot success line
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) wait_for_monitor 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) # try to reboot normally
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) if (run_command $reboot) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) if (defined($powercycle_after_reboot)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) sleep $powercycle_after_reboot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) run_command "$power_cycle";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) # nope? power cycle it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) run_command "$power_cycle";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) if (defined($time)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) # We only want to get to the new kernel, don't fail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) # if we stumble over a call trace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) my $save_ignore_errors = $ignore_errors;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) $ignore_errors = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) # Look for the good kernel to boot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) if (wait_for_monitor($time, "Linux version")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) # reboot got stuck?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) doprint "Reboot did not finish. Forcing power cycle\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) run_command "$power_cycle";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) $ignore_errors = $save_ignore_errors;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) # Still need to wait for the reboot to finish
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) wait_for_monitor($time, $reboot_success_line);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) end_monitor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) sub reboot_to_good {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) my ($time) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) if (defined($switch_to_good)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) run_command $switch_to_good;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) reboot $time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) sub do_not_reboot {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) my $i = $iteration;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) return $test_type eq "build" || $no_reboot ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) ($test_type eq "patchcheck" && $opt{"PATCHCHECK_TYPE[$i]"} eq "build") ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) ($test_type eq "bisect" && $opt{"BISECT_TYPE[$i]"} eq "build") ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) ($test_type eq "config_bisect" && $opt{"CONFIG_BISECT_TYPE[$i]"} eq "build");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) my $in_die = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) sub get_test_name() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) my $name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) if (defined($test_name)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) $name = "$test_name:$test_type";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) $name = $test_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) return $name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) sub dodie {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) # avoid recursion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) return if ($in_die);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) $in_die = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) my $i = $iteration;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) doprint "CRITICAL FAILURE... [TEST $i] ", @_, "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) if ($reboot_on_error && !do_not_reboot) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) doprint "REBOOTING\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) reboot_to_good;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) } elsif ($poweroff_on_error && defined($power_off)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) doprint "POWERING OFF\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) `$power_off`;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) if (defined($opt{"LOG_FILE"})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) print " See $opt{LOG_FILE} for more info.\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) if ($email_on_error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) my $name = get_test_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) my $log_file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) if (defined($opt{"LOG_FILE"})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) my $whence = 2; # End of file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) my $log_size = tell LOG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) my $size = $log_size - $test_log_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) if (defined($mail_max_size)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) if ($size > $mail_max_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) $size = $mail_max_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) my $pos = - $size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) $log_file = "$tmpdir/log";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) open (L, "$opt{LOG_FILE}") or die "Can't open $opt{LOG_FILE} to read)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) open (O, "> $tmpdir/log") or die "Can't open $tmpdir/log\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) seek(L, $pos, $whence);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) while (<L>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) print O;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) close O;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) close L;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) send_email("KTEST: critical failure for test $i [$name]",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) "Your test started at $script_start_time has failed with:\n@_\n", $log_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) if ($monitor_cnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) # restore terminal settings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) system("stty $stty_orig");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) if (defined($post_test)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) run_command $post_test;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) die @_, "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) sub create_pty {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) my ($ptm, $pts) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) my $tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) my $TIOCSPTLCK = 0x40045431;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) my $TIOCGPTN = 0x80045430;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) sysopen($ptm, "/dev/ptmx", O_RDWR | O_NONBLOCK) or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) dodie "Can't open /dev/ptmx";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) # unlockpt()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) $tmp = pack("i", 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) ioctl($ptm, $TIOCSPTLCK, $tmp) or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) dodie "ioctl TIOCSPTLCK for /dev/ptmx failed";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) # ptsname()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) ioctl($ptm, $TIOCGPTN, $tmp) or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) dodie "ioctl TIOCGPTN for /dev/ptmx failed";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) $tmp = unpack("i", $tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) sysopen($pts, "/dev/pts/$tmp", O_RDWR | O_NONBLOCK) or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) dodie "Can't open /dev/pts/$tmp";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) sub exec_console {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) my ($ptm, $pts) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564) close($ptm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) close(\*STDIN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) close(\*STDOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) close(\*STDERR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) open(\*STDIN, '<&', $pts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) open(\*STDOUT, '>&', $pts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) open(\*STDERR, '>&', $pts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) close($pts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) exec $console or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) dodie "Can't open console $console";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) sub open_console {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) my ($ptm) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) my $pts = \*PTSFD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) my $pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) # save terminal settings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) $stty_orig = `stty -g`;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) # place terminal in cbreak mode so that stdin can be read one character at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) # a time without having to wait for a newline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) system("stty -icanon -echo -icrnl");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) create_pty($ptm, $pts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) $pid = fork;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) if (!$pid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) # child
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) exec_console($ptm, $pts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) # parent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) close($pts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) return $pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) open(PTSFD, "Stop perl from warning about single use of PTSFD");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) sub close_console {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) my ($fp, $pid) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) doprint "kill child process $pid\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) kill $close_console_signal, $pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) doprint "wait for child process $pid to exit\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) waitpid($pid, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) print "closing!\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) close($fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) # restore terminal settings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) system("stty $stty_orig");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) sub start_monitor {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) if ($monitor_cnt++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) $monitor_fp = \*MONFD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) $monitor_pid = open_console $monitor_fp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) open(MONFD, "Stop perl from warning about single use of MONFD");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) sub end_monitor {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) return if (!defined $console);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) if (--$monitor_cnt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) close_console($monitor_fp, $monitor_pid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) sub wait_for_monitor {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) my ($time, $stop) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647) my $full_line = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) my $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) my $booted = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) my $start_time = time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) my $skip_call_trace = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) my $bug = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653) my $bug_ignored = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) my $now;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) doprint "** Wait for monitor to settle down **\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) # read the monitor and wait for the system to calm down
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) while (!$booted) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) $line = wait_for_input($monitor_fp, $time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) last if (!defined($line));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662) print "$line";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) $full_line .= $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) if (defined($stop) && $full_line =~ /$stop/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) doprint "wait for monitor detected $stop\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) $booted = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) if ($full_line =~ /\[ backtrace testing \]/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) $skip_call_trace = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) if ($full_line =~ /call trace:/i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) if (!$bug && !$skip_call_trace) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) if ($ignore_errors) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) $bug_ignored = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) $bug = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) if ($full_line =~ /\[ end of backtrace testing \]/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685) $skip_call_trace = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) if ($full_line =~ /Kernel panic -/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) $bug = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692) if ($line =~ /\n/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693) $full_line = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) $now = time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) if ($now - $start_time >= $max_monitor_wait) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) doprint "Exiting monitor flush due to hitting MAX_MONITOR_WAIT\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) print "** Monitor flushed **\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) # if stop is defined but wasn't hit, return error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) # used by reboot (which wants to see a reboot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705) if (defined($stop) && !$booted) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706) $bug = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) return $bug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) sub save_logs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712) my ($result, $basedir) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713) my @t = localtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) my $date = sprintf "%04d%02d%02d%02d%02d%02d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) 1900+$t[5],$t[4],$t[3],$t[2],$t[1],$t[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) my $type = $build_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718) if ($type =~ /useconfig/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) $type = "useconfig";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) my $dir = "$machine-$test_type-$type-$result-$date";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) $dir = "$basedir/$dir";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726) if (!-d $dir) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) mkpath($dir) or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728) dodie "can't create $dir";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731) my %files = (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) "config" => $output_config,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) "buildlog" => $buildlog,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) "dmesg" => $dmesg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735) "testlog" => $testlog,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) while (my ($name, $source) = each(%files)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739) if (-f "$source") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) cp "$source", "$dir/$name" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) dodie "failed to copy $source";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) doprint "*** Saved info to $dir ***\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748) sub fail {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) if ($die_on_failure) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751) dodie @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) doprint "FAILED\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) my $i = $iteration;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758) # no need to reboot for just building.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) if (!do_not_reboot) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760) doprint "REBOOTING\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) reboot_to_good $sleep_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764) my $name = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) if (defined($test_name)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) $name = " ($test_name)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770) print_times;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772) doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773) doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) doprint "KTEST RESULT: TEST $i$name Failed: ", @_, "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776) doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) if (defined($store_failures)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) save_logs "fail", $store_failures;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782) if (defined($post_test)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) run_command $post_test;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789) sub run_command {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) my ($command, $redirect, $timeout) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) my $start_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) my $end_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) my $dolog = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) my $dord = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) my $dostdout = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) my $pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) my $command_orig = $command;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799) $command =~ s/\$SSH_USER/$ssh_user/g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) $command =~ s/\$MACHINE/$machine/g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802) doprint("$command ... ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) $start_time = time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805) $pid = open(CMD, "$command 2>&1 |") or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806) (fail "unable to exec $command" and return 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808) if (defined($opt{"LOG_FILE"})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) $dolog = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812) if (defined($redirect)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) if ($redirect eq 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814) $dostdout = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815) # Have the output of the command on its own line
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816) doprint "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818) open (RD, ">$redirect") or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819) dodie "failed to write to redirect $redirect";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820) $dord = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) my $hit_timeout = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826) while (1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827) my $fp = \*CMD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) if (defined($timeout)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829) doprint "timeout = $timeout\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) my $line = wait_for_input($fp, $timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832) if (!defined($line)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833) my $now = time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834) if (defined($timeout) && (($now - $start_time) >= $timeout)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835) doprint "Hit timeout of $timeout, killing process\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) $hit_timeout = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837) kill 9, $pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839) last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) print LOG $line if ($dolog);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842) print RD $line if ($dord);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843) print $line if ($dostdout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) waitpid($pid, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847) # shift 8 for real exit status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848) $run_command_status = $? >> 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850) if ($command_orig eq $default{REBOOT} &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) $run_command_status == $reboot_return_code) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852) $run_command_status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855) close(CMD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856) close(RD) if ($dord);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858) $end_time = time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859) my $delta = $end_time - $start_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861) if ($delta == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862) doprint "[1 second] ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864) doprint "[$delta seconds] ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867) if ($hit_timeout) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868) $run_command_status = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871) if ($run_command_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872) doprint "FAILED!\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874) doprint "SUCCESS\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877) return !$run_command_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880) sub run_ssh {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881) my ($cmd, $timeout) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882) my $cp_exec = $ssh_exec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884) $cp_exec =~ s/\$SSH_COMMAND/$cmd/g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885) return run_command "$cp_exec", undef , $timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888) sub run_scp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889) my ($src, $dst, $cp_scp) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891) $cp_scp =~ s/\$SRC_FILE/$src/g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892) $cp_scp =~ s/\$DST_FILE/$dst/g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1894) return run_command "$cp_scp";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1895) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1896)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897) sub run_scp_install {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898) my ($src, $dst) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900) my $cp_scp = $scp_to_target_install;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902) return run_scp($src, $dst, $cp_scp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905) sub run_scp_mod {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906) my ($src, $dst) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1908) my $cp_scp = $scp_to_target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1909)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1910) return run_scp($src, $dst, $cp_scp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1911) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913) sub _get_grub_index {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915) my ($command, $target, $skip) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917) return if (defined($grub_number) && defined($last_grub_menu) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918) $last_grub_menu eq $grub_menu && defined($last_machine) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919) $last_machine eq $machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921) doprint "Find $reboot_type menu ... ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922) $grub_number = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924) my $ssh_grub = $ssh_exec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1925) $ssh_grub =~ s,\$SSH_COMMAND,$command,g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1926)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1927) open(IN, "$ssh_grub |")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1928) or dodie "unable to execute $command";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1929)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1930) my $found = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1931)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1932) while (<IN>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1933) if (/$target/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1934) $grub_number++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1935) $found = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1936) last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1937) } elsif (/$skip/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1938) $grub_number++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1939) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1940) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1941) close(IN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1942)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1943) dodie "Could not find '$grub_menu' through $command on $machine"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1944) if (!$found);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1945) doprint "$grub_number\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1946) $last_grub_menu = $grub_menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1947) $last_machine = $machine;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1948) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1949)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1950) sub get_grub_index {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1951)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1952) my $command;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1953) my $target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1954) my $skip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1955) my $grub_menu_qt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1956)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1957) if ($reboot_type !~ /^grub/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1958) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1959) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1960)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1961) $grub_menu_qt = quotemeta($grub_menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1962)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1963) if ($reboot_type eq "grub") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1964) $command = "cat /boot/grub/menu.lst";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1965) $target = '^\s*title\s+' . $grub_menu_qt . '\s*$';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1966) $skip = '^\s*title\s';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1967) } elsif ($reboot_type eq "grub2") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1968) $command = "cat $grub_file";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1969) $target = '^menuentry.*' . $grub_menu_qt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1970) $skip = '^menuentry\s|^submenu\s';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1971) } elsif ($reboot_type eq "grub2bls") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1972) $command = $grub_bls_get;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1973) $target = '^title=.*' . $grub_menu_qt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1974) $skip = '^title=';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1975) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1976) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1977) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1978)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1979) _get_grub_index($command, $target, $skip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1980) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1981)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1982) sub wait_for_input
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1983) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1984) my ($fp, $time) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1985) my $start_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1986) my $rin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1987) my $rout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1988) my $nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1989) my $buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1990) my $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1991) my $ch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1992)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1993) if (!defined($time)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1994) $time = $timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1995) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1996)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1997) $rin = '';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1998) vec($rin, fileno($fp), 1) = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1999) vec($rin, fileno(\*STDIN), 1) = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2001) $start_time = time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2003) while (1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2004) $nr = select($rout=$rin, undef, undef, $time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2005)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2006) last if ($nr <= 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2007)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2008) # copy data from stdin to the console
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2009) if (vec($rout, fileno(\*STDIN), 1) == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2010) $nr = sysread(\*STDIN, $buf, 1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2011) syswrite($fp, $buf, $nr) if ($nr > 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2012) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2013)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2014) # The timeout is based on time waiting for the fp data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2015) if (vec($rout, fileno($fp), 1) != 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2016) last if (defined($time) && (time - $start_time > $time));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2017) next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2018) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2019)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2020) $line = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2021)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2022) # try to read one char at a time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2023) while (sysread $fp, $ch, 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2024) $line .= $ch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2025) last if ($ch eq "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2026) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2027)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2028) last if (!length($line));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2029)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2030) return $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2031) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2032) return undef;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2033) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2034)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2035) sub reboot_to {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2036) if (defined($switch_to_test)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2037) run_command $switch_to_test;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2038) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2039)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2040) if ($reboot_type eq "grub") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2041) run_ssh "'(echo \"savedefault --default=$grub_number --once\" | grub --batch)'";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2042) } elsif (($reboot_type eq "grub2") or ($reboot_type eq "grub2bls")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2043) run_ssh "$grub_reboot $grub_number";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2044) } elsif ($reboot_type eq "syslinux") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2045) run_ssh "$syslinux --once \\\"$syslinux_label\\\" $syslinux_path";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2046) } elsif (defined $reboot_script) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2047) run_command "$reboot_script";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2048) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2049) reboot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2050) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2051)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2052) sub get_sha1 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2053) my ($commit) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2054)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2055) doprint "git rev-list --max-count=1 $commit ... ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2056) my $sha1 = `git rev-list --max-count=1 $commit`;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2057) my $ret = $?;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2058)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2059) logit $sha1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2060)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2061) if ($ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2062) doprint "FAILED\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2063) dodie "Failed to get git $commit";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2064) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2065)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2066) print "SUCCESS\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2067)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2068) chomp $sha1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2069)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2070) return $sha1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2071) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2072)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2073) sub monitor {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2074) my $booted = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2075) my $bug = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2076) my $bug_ignored = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2077) my $skip_call_trace = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2078) my $loops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2079)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2080) my $start_time = time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2081)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2082) wait_for_monitor 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2083)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2084) my $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2085) my $full_line = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2086)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2087) open(DMESG, "> $dmesg") or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2088) dodie "unable to write to $dmesg";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2089)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2090) reboot_to;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2091)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2092) my $success_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2093) my $failure_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2094) my $monitor_start = time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2095) my $done = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2096) my $version_found = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2097)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2098) while (!$done) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2099)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2100) if ($bug && defined($stop_after_failure) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2101) $stop_after_failure >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2102) my $time = $stop_after_failure - (time - $failure_start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2103) $line = wait_for_input($monitor_fp, $time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2104) if (!defined($line)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2105) doprint "bug timed out after $booted_timeout seconds\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2106) doprint "Test forced to stop after $stop_after_failure seconds after failure\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2107) last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2109) } elsif ($booted) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2110) $line = wait_for_input($monitor_fp, $booted_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2111) if (!defined($line)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2112) my $s = $booted_timeout == 1 ? "" : "s";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2113) doprint "Successful boot found: break after $booted_timeout second$s\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2114) last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2116) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2117) $line = wait_for_input($monitor_fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2118) if (!defined($line)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2119) my $s = $timeout == 1 ? "" : "s";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2120) doprint "Timed out after $timeout second$s\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2121) last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2123) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2125) doprint $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2126) print DMESG $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2128) # we are not guaranteed to get a full line
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2129) $full_line .= $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2131) if ($full_line =~ /$success_line/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2132) $booted = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2133) $success_start = time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2134) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2136) if ($booted && defined($stop_after_success) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2137) $stop_after_success >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2138) my $now = time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2139) if ($now - $success_start >= $stop_after_success) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2140) doprint "Test forced to stop after $stop_after_success seconds after success\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2141) last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2145) if ($full_line =~ /\[ backtrace testing \]/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2146) $skip_call_trace = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2147) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2149) if ($full_line =~ /call trace:/i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2150) if (!$bug && !$skip_call_trace) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2151) if ($ignore_errors) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2152) $bug_ignored = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2153) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2154) $bug = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2155) $failure_start = time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2156) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2160) if ($bug && defined($stop_after_failure) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2161) $stop_after_failure >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2162) my $now = time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2163) if ($now - $failure_start >= $stop_after_failure) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2164) doprint "Test forced to stop after $stop_after_failure seconds after failure\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2165) last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2169) if ($full_line =~ /\[ end of backtrace testing \]/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2170) $skip_call_trace = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2171) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2173) if ($full_line =~ /Kernel panic -/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2174) $failure_start = time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2175) $bug = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2176) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2178) # Detect triple faults by testing the banner
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2179) if ($full_line =~ /\bLinux version (\S+).*\n/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2180) if ($1 eq $version) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2181) $version_found = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2182) } elsif ($version_found && $detect_triplefault) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2183) # We already booted into the kernel we are testing,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2184) # but now we booted into another kernel?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2185) # Consider this a triple fault.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2186) doprint "Already booted in Linux kernel $version, but now\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2187) doprint "we booted into Linux kernel $1.\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2188) doprint "Assuming that this is a triple fault.\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2189) doprint "To disable this: set DETECT_TRIPLE_FAULT to 0\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2190) last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2192) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2194) if ($line =~ /\n/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2195) $full_line = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2198) if ($stop_test_after > 0 && !$booted && !$bug) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2199) if (time - $monitor_start > $stop_test_after) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2200) doprint "STOP_TEST_AFTER ($stop_test_after seconds) timed out\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2201) $done = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2204) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2206) my $end_time = time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2207) $reboot_time = $end_time - $start_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2209) close(DMESG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2211) if ($bug) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2212) return 0 if ($in_bisect);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2213) fail "failed - got a bug report" and return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2216) if (!$booted) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2217) return 0 if ($in_bisect);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2218) fail "failed - never got a boot prompt." and return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2219) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2221) if ($bug_ignored) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2222) doprint "WARNING: Call Trace detected but ignored due to IGNORE_ERRORS=1\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2225) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2226) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2228) sub eval_kernel_version {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2229) my ($option) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2231) $option =~ s/\$KERNEL_VERSION/$version/g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2233) return $option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2236) sub do_post_install {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2238) return if (!defined($post_install));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2240) my $cp_post_install = eval_kernel_version $post_install;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2241) run_command "$cp_post_install" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2242) dodie "Failed to run post install";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2243) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2245) # Sometimes the reboot fails, and will hang. We try to ssh to the box
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2246) # and if we fail, we force another reboot, that should powercycle it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2247) sub test_booted {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2248) if (!run_ssh "echo testing connection") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2249) reboot $sleep_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2251) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2253) sub install {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2255) return if ($no_install);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2257) my $start_time = time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2259) if (defined($pre_install)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2260) my $cp_pre_install = eval_kernel_version $pre_install;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2261) run_command "$cp_pre_install" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2262) dodie "Failed to run pre install";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2263) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2265) my $cp_target = eval_kernel_version $target_image;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2267) test_booted;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2269) run_scp_install "$outputdir/$build_target", "$cp_target" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2270) dodie "failed to copy image";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2272) my $install_mods = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2274) # should we process modules?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2275) $install_mods = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2276) open(IN, "$output_config") or dodie("Can't read config file");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2277) while (<IN>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2278) if (/CONFIG_MODULES(=y)?/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2279) if (defined($1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2280) $install_mods = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2281) last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2282) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2283) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2284) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2285) close(IN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2287) if (!$install_mods) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2288) do_post_install;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2289) doprint "No modules needed\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2290) my $end_time = time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2291) $install_time = $end_time - $start_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2292) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2293) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2295) run_command "$make INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=$tmpdir modules_install" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2296) dodie "Failed to install modules";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2298) my $modlib = "/lib/modules/$version";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2299) my $modtar = "ktest-mods.tar.bz2";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2301) run_ssh "rm -rf $modlib" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2302) dodie "failed to remove old mods: $modlib";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2304) # would be nice if scp -r did not follow symbolic links
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2305) run_command "cd $tmpdir && tar -cjf $modtar lib/modules/$version" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2306) dodie "making tarball";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2308) run_scp_mod "$tmpdir/$modtar", "/tmp" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2309) dodie "failed to copy modules";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2311) unlink "$tmpdir/$modtar";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2313) run_ssh "'(cd / && tar xjf /tmp/$modtar)'" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2314) dodie "failed to tar modules";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2316) run_ssh "rm -f /tmp/$modtar";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2318) do_post_install;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2320) my $end_time = time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2321) $install_time = $end_time - $start_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2322) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2324) sub get_version {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2325) # get the release name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2326) return if ($have_version);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2327) doprint "$make kernelrelease ... ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2328) $version = `$make -s kernelrelease | tail -1`;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2329) chomp($version);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2330) doprint "$version\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2331) $have_version = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2332) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2334) sub start_monitor_and_install {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2335) # Make sure the stable kernel has finished booting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2337) # Install bisects, don't need console
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2338) if (defined $console) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2339) start_monitor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2340) wait_for_monitor 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2341) end_monitor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2342) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2344) get_grub_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2345) get_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2346) install;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2348) start_monitor if (defined $console);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2349) return monitor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2350) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2352) my $check_build_re = ".*:.*(warning|error|Error):.*";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2353) my $utf8_quote = "\\x{e2}\\x{80}(\\x{98}|\\x{99})";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2355) sub process_warning_line {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2356) my ($line) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2358) chomp $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2360) # for distcc heterogeneous systems, some compilers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2361) # do things differently causing warning lines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2362) # to be slightly different. This makes an attempt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2363) # to fixe those issues.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2365) # chop off the index into the line
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2366) # using distcc, some compilers give different indexes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2367) # depending on white space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2368) $line =~ s/^(\s*\S+:\d+:)\d+/$1/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2370) # Some compilers use UTF-8 extended for quotes and some don't.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2371) $line =~ s/$utf8_quote/'/g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2373) return $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2374) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2376) # Read buildlog and check against warnings file for any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2377) # new warnings.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2378) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2379) # Returns 1 if OK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2380) # 0 otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2381) sub check_buildlog {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2382) return 1 if (!defined $warnings_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2384) my %warnings_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2385)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2386) # Failed builds should not reboot the target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2387) my $save_no_reboot = $no_reboot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2388) $no_reboot = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2389)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2390) if (-f $warnings_file) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2391) open(IN, $warnings_file) or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2392) dodie "Error opening $warnings_file";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2394) while (<IN>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2395) if (/$check_build_re/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2396) my $warning = process_warning_line $_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2398) $warnings_list{$warning} = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2399) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2400) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2401) close(IN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2402) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2404) # If warnings file didn't exist, and WARNINGS_FILE exist,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2405) # then we fail on any warning!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2407) open(IN, $buildlog) or dodie "Can't open $buildlog";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2408) while (<IN>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2409) if (/$check_build_re/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2410) my $warning = process_warning_line $_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2412) if (!defined $warnings_list{$warning}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2413) fail "New warning found (not in $warnings_file)\n$_\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2414) $no_reboot = $save_no_reboot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2415) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2416) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2417) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2418) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2419) $no_reboot = $save_no_reboot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2420) close(IN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2421) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2422)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2423) sub check_patch_buildlog {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2424) my ($patch) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2426) my @files = `git show $patch | diffstat -l`;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2428) foreach my $file (@files) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2429) chomp $file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2430) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2431)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2432) open(IN, "git show $patch |") or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2433) dodie "failed to show $patch";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2434) while (<IN>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2435) if (m,^--- a/(.*),) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2436) chomp $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2437) $files[$#files] = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2438) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2439) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2440) close(IN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2442) open(IN, $buildlog) or dodie "Can't open $buildlog";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2443) while (<IN>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2444) if (/^\s*(.*?):.*(warning|error)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2445) my $err = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2446) foreach my $file (@files) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2447) my $fullpath = "$builddir/$file";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2448) if ($file eq $err || $fullpath eq $err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2449) fail "$file built with warnings" and return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2450) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2451) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2452) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2453) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2454) close(IN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2456) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2457) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2458)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2459) sub apply_min_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2460) my $outconfig = "$output_config.new";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2462) # Read the config file and remove anything that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2463) # is in the force_config hash (from minconfig and others)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2464) # then add the force config back.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2466) doprint "Applying minimum configurations into $output_config.new\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2468) open (OUT, ">$outconfig") or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2469) dodie "Can't create $outconfig";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2471) if (-f $output_config) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2472) open (IN, $output_config) or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2473) dodie "Failed to open $output_config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2474) while (<IN>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2475) if (/^(# )?(CONFIG_[^\s=]*)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2476) next if (defined($force_config{$2}));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2477) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2478) print OUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2479) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2480) close IN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2481) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2482) foreach my $config (keys %force_config) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2483) print OUT "$force_config{$config}\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2484) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2485) close OUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2486)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2487) run_command "mv $outconfig $output_config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2488) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2490) sub make_oldconfig {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2491)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2492) my @force_list = keys %force_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2494) if ($#force_list >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2495) apply_min_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2496) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2497)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2498) if (!run_command "$make olddefconfig") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2499) # Perhaps olddefconfig doesn't exist in this version of the kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2500) # try oldnoconfig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2501) doprint "olddefconfig failed, trying make oldnoconfig\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2502) if (!run_command "$make oldnoconfig") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2503) doprint "oldnoconfig failed, trying yes '' | make oldconfig\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2504) # try a yes '' | oldconfig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2505) run_command "yes '' | $make oldconfig" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2506) dodie "failed make config oldconfig";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2507) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2508) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2509) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2510)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2511) # read a config file and use this to force new configs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2512) sub load_force_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2513) my ($config) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2514)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2515) doprint "Loading force configs from $config\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2516) open(IN, $config) or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2517) dodie "failed to read $config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2518) while (<IN>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2519) chomp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2520) if (/^(CONFIG[^\s=]*)(\s*=.*)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2521) $force_config{$1} = $_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2522) } elsif (/^# (CONFIG_\S*) is not set/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2523) $force_config{$1} = $_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2524) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2525) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2526) close IN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2527) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2528)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2529) sub build {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2530) my ($type) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2532) unlink $buildlog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2533)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2534) my $start_time = time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2536) # Failed builds should not reboot the target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2537) my $save_no_reboot = $no_reboot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2538) $no_reboot = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2539)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2540) # Calculate a new version from here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2541) $have_version = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2542)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2543) if (defined($pre_build)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2544) my $ret = run_command $pre_build;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2545) if (!$ret && defined($pre_build_die) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2546) $pre_build_die) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2547) dodie "failed to pre_build\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2548) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2549) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2551) if ($type =~ /^useconfig:(.*)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2552) run_command "cp $1 $output_config" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2553) dodie "could not copy $1 to .config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2554)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2555) $type = "oldconfig";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2556) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2558) # old config can ask questions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2559) if ($type eq "oldconfig") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2560) $type = "olddefconfig";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2561)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2562) # allow for empty configs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2563) run_command "touch $output_config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2564)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2565) if (!$noclean) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2566) run_command "mv $output_config $outputdir/config_temp" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2567) dodie "moving .config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2568)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2569) run_command "$make mrproper" or dodie "make mrproper";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2571) run_command "mv $outputdir/config_temp $output_config" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2572) dodie "moving config_temp";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2573) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2574)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2575) } elsif (!$noclean) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2576) unlink "$output_config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2577) run_command "$make mrproper" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2578) dodie "make mrproper";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2579) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2581) # add something to distinguish this build
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2582) open(OUT, "> $outputdir/localversion") or dodie("Can't make localversion file");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2583) print OUT "$localversion\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2584) close(OUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2586) if (defined($minconfig)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2587) load_force_config($minconfig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2588) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2589)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2590) if ($type ne "olddefconfig") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2591) run_command "$make $type" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2592) dodie "failed make config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2593) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2594) # Run old config regardless, to enforce min configurations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2595) make_oldconfig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2596)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2597) my $build_ret = run_command "$make $build_options", $buildlog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2598)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2599) if (defined($post_build)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2600) # Because a post build may change the kernel version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2601) # do it now.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2602) get_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2603) my $ret = run_command $post_build;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2604) if (!$ret && defined($post_build_die) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2605) $post_build_die) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2606) dodie "failed to post_build\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2607) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2608) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2609)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2610) if (!$build_ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2611) # bisect may need this to pass
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2612) if ($in_bisect) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2613) $no_reboot = $save_no_reboot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2614) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2615) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2616) fail "failed build" and return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2617) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2618)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2619) $no_reboot = $save_no_reboot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2620)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2621) my $end_time = time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2622) $build_time = $end_time - $start_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2623)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2624) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2625) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2626)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2627) sub halt {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2628) if (!run_ssh "halt" or defined($power_off)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2629) if (defined($poweroff_after_halt)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2630) sleep $poweroff_after_halt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2631) run_command "$power_off";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2632) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2633) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2634) # nope? the zap it!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2635) run_command "$power_off";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2636) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2637) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2638)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2639) sub success {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2640) my ($i) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2642) $successes++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2643)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2644) my $name = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2645)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2646) if (defined($test_name)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2647) $name = " ($test_name)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2648) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2649)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2650) print_times;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2651)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2652) doprint "\n\n*******************************************\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2653) doprint "*******************************************\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2654) doprint "KTEST RESULT: TEST $i$name SUCCESS!!!! **\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2655) doprint "*******************************************\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2656) doprint "*******************************************\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2657)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2658) if (defined($store_successes)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2659) save_logs "success", $store_successes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2660) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2661)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2662) if ($i != $opt{"NUM_TESTS"} && !do_not_reboot) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2663) doprint "Reboot and wait $sleep_time seconds\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2664) reboot_to_good $sleep_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2665) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2666)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2667) if (defined($post_test)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2668) run_command $post_test;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2669) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2670) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2671)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2672) sub answer_bisect {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2673) for (;;) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2674) doprint "Pass, fail, or skip? [p/f/s]";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2675) my $ans = <STDIN>;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2676) chomp $ans;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2677) if ($ans eq "p" || $ans eq "P") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2678) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2679) } elsif ($ans eq "f" || $ans eq "F") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2680) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2681) } elsif ($ans eq "s" || $ans eq "S") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2682) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2683) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2684) print "Please answer 'p', 'f', or 's'\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2685) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2686) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2687) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2689) sub child_run_test {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2690)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2691) # child should have no power
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2692) $reboot_on_error = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2693) $poweroff_on_error = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2694) $die_on_failure = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2695)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2696) run_command $run_test, $testlog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2697)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2698) exit $run_command_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2699) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2700)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2701) my $child_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2703) sub child_finished {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2704) $child_done = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2705) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2706)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2707) sub do_run_test {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2708) my $child_pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2709) my $child_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2710) my $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2711) my $full_line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2712) my $bug = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2713) my $bug_ignored = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2714)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2715) my $start_time = time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2716)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2717) wait_for_monitor 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2718)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2719) doprint "run test $run_test\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2720)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2721) $child_done = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2722)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2723) $SIG{CHLD} = qw(child_finished);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2724)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2725) $child_pid = fork;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2726)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2727) child_run_test if (!$child_pid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2729) $full_line = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2730)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2731) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2732) $line = wait_for_input($monitor_fp, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2733) if (defined($line)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2734)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2735) # we are not guaranteed to get a full line
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2736) $full_line .= $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2737) doprint $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2738)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2739) if ($full_line =~ /call trace:/i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2740) if ($ignore_errors) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2741) $bug_ignored = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2742) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2743) $bug = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2744) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2745) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2746)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2747) if ($full_line =~ /Kernel panic -/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2748) $bug = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2749) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2750)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2751) if ($line =~ /\n/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2752) $full_line = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2753) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2754) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2755) } while (!$child_done && !$bug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2756)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2757) if (!$bug && $bug_ignored) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2758) doprint "WARNING: Call Trace detected but ignored due to IGNORE_ERRORS=1\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2759) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2761) if ($bug) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2762) my $failure_start = time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2763) my $now;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2764) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2765) $line = wait_for_input($monitor_fp, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2766) if (defined($line)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2767) doprint $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2768) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2769) $now = time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2770) if ($now - $failure_start >= $stop_after_failure) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2771) last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2772) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2773) } while (defined($line));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2774)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2775) doprint "Detected kernel crash!\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2776) # kill the child with extreme prejudice
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2777) kill 9, $child_pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2778) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2779)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2780) waitpid $child_pid, 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2781) $child_exit = $? >> 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2782)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2783) my $end_time = time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2784) $test_time = $end_time - $start_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2785)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2786) if (!$bug && $in_bisect) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2787) if (defined($bisect_ret_good)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2788) if ($child_exit == $bisect_ret_good) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2789) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2790) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2791) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2792) if (defined($bisect_ret_skip)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2793) if ($child_exit == $bisect_ret_skip) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2794) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2795) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2796) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2797) if (defined($bisect_ret_abort)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2798) if ($child_exit == $bisect_ret_abort) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2799) fail "test abort" and return -2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2800) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2801) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2802) if (defined($bisect_ret_bad)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2803) if ($child_exit == $bisect_ret_skip) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2804) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2805) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2806) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2807) if (defined($bisect_ret_default)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2808) if ($bisect_ret_default eq "good") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2809) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2810) } elsif ($bisect_ret_default eq "bad") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2811) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2812) } elsif ($bisect_ret_default eq "skip") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2813) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2814) } elsif ($bisect_ret_default eq "abort") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2815) return -2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2816) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2817) fail "unknown default action: $bisect_ret_default"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2818) and return -2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2819) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2820) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2821) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2822)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2823) if ($bug || $child_exit) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2824) return 0 if $in_bisect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2825) fail "test failed" and return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2826) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2827) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2828) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2829)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2830) sub run_git_bisect {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2831) my ($command) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2832)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2833) doprint "$command ... ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2834)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2835) my $output = `$command 2>&1`;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2836) my $ret = $?;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2837)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2838) logit $output;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2839)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2840) if ($ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2841) doprint "FAILED\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2842) dodie "Failed to git bisect";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2843) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2844)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2845) doprint "SUCCESS\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2846) if ($output =~ m/^(Bisecting: .*\(roughly \d+ steps?\))\s+\[([[:xdigit:]]+)\]/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2847) doprint "$1 [$2]\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2848) } elsif ($output =~ m/^([[:xdigit:]]+) is the first bad commit/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2849) $bisect_bad_commit = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2850) doprint "Found bad commit... $1\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2851) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2852) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2853) # we already logged it, just print it now.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2854) print $output;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2855) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2856)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2857) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2858) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2859)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2860) sub bisect_reboot {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2861) doprint "Reboot and sleep $bisect_sleep_time seconds\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2862) reboot_to_good $bisect_sleep_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2863) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2864)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2865) # returns 1 on success, 0 on failure, -1 on skip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2866) sub run_bisect_test {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2867) my ($type, $buildtype) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2868)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2869) my $failed = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2870) my $result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2871) my $output;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2872) my $ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2873)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2874) $in_bisect = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2875)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2876) build $buildtype or $failed = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2877)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2878) if ($type ne "build") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2879) if ($failed && $bisect_skip) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2880) $in_bisect = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2881) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2882) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2883) dodie "Failed on build" if $failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2884)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2885) # Now boot the box
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2886) start_monitor_and_install or $failed = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2887)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2888) if ($type ne "boot") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2889) if ($failed && $bisect_skip) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2890) end_monitor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2891) bisect_reboot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2892) $in_bisect = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2893) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2894) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2895) dodie "Failed on boot" if $failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2896)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2897) do_run_test or $failed = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2898) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2899) end_monitor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2900) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2901)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2902) if ($failed) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2903) $result = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2904) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2905) $result = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2906) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2907)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2908) # reboot the box to a kernel we can ssh to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2909) if ($type ne "build") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2910) bisect_reboot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2911) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2912) $in_bisect = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2913)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2914) return $result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2915) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2916)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2917) sub run_bisect {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2918) my ($type) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2919) my $buildtype = "oldconfig";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2920)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2921) # We should have a minconfig to use?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2922) if (defined($minconfig)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2923) $buildtype = "useconfig:$minconfig";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2924) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2925)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2926) # If the user sets bisect_tries to less than 1, then no tries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2927) # is a success.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2928) my $ret = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2929)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2930) # Still let the user manually decide that though.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2931) if ($bisect_tries < 1 && $bisect_manual) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2932) $ret = answer_bisect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2933) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2934)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2935) for (my $i = 0; $i < $bisect_tries; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2936) if ($bisect_tries > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2937) my $t = $i + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2938) doprint("Running bisect trial $t of $bisect_tries:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2939) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2940) $ret = run_bisect_test $type, $buildtype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2941)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2942) if ($bisect_manual) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2943) $ret = answer_bisect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2944) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2945)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2946) last if (!$ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2947) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2948)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2949) # Are we looking for where it worked, not failed?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2950) if ($reverse_bisect && $ret >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2951) $ret = !$ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2952) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2953)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2954) if ($ret > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2955) return "good";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2956) } elsif ($ret == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2957) return "bad";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2958) } elsif ($bisect_skip) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2959) doprint "HIT A BAD COMMIT ... SKIPPING\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2960) return "skip";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2961) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2962) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2963)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2964) sub update_bisect_replay {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2965) my $tmp_log = "$tmpdir/ktest_bisect_log";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2966) run_command "git bisect log > $tmp_log" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2967) dodie "can't create bisect log";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2968) return $tmp_log;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2969) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2970)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2971) sub bisect {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2972) my ($i) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2973)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2974) my $result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2975)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2976) dodie "BISECT_GOOD[$i] not defined\n" if (!defined($bisect_good));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2977) dodie "BISECT_BAD[$i] not defined\n" if (!defined($bisect_bad));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2978) dodie "BISECT_TYPE[$i] not defined\n" if (!defined($bisect_type));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2979)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2980) my $good = $bisect_good;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2981) my $bad = $bisect_bad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2982) my $type = $bisect_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2983) my $start = $bisect_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2984) my $replay = $bisect_replay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2985) my $start_files = $bisect_files;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2986)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2987) if (defined($start_files)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2988) $start_files = " -- " . $start_files;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2989) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2990) $start_files = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2991) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2992)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2993) # convert to true sha1's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2994) $good = get_sha1($good);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2995) $bad = get_sha1($bad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2996)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2997) if (defined($bisect_reverse) && $bisect_reverse == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2998) doprint "Performing a reverse bisect (bad is good, good is bad!)\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2999) $reverse_bisect = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3000) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3001) $reverse_bisect = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3002) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3003)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3004) # Can't have a test without having a test to run
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3005) if ($type eq "test" && !defined($run_test)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3006) $type = "boot";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3007) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3008)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3009) # Check if a bisect was running
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3010) my $bisect_start_file = "$builddir/.git/BISECT_START";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3011)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3012) my $check = $bisect_check;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3013) my $do_check = defined($check) && $check ne "0";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3014)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3015) if ( -f $bisect_start_file ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3016) print "Bisect in progress found\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3017) if ($do_check) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3018) print " If you say yes, then no checks of good or bad will be done\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3019) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3020) if (defined($replay)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3021) print "** BISECT_REPLAY is defined in config file **";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3022) print " Ignore config option and perform new git bisect log?\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3023) if (read_ync " (yes, no, or cancel) ") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3024) $replay = update_bisect_replay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3025) $do_check = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3026) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3027) } elsif (read_yn "read git log and continue?") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3028) $replay = update_bisect_replay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3029) $do_check = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3030) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3031) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3032)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3033) if ($do_check) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3034)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3035) # get current HEAD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3036) my $head = get_sha1("HEAD");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3037)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3038) if ($check ne "good") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3039) doprint "TESTING BISECT BAD [$bad]\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3040) run_command "git checkout $bad" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3041) dodie "Failed to checkout $bad";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3042)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3043) $result = run_bisect $type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3044)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3045) if ($result ne "bad") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3046) fail "Tested BISECT_BAD [$bad] and it succeeded" and return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3047) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3048) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3049)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3050) if ($check ne "bad") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3051) doprint "TESTING BISECT GOOD [$good]\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3052) run_command "git checkout $good" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3053) dodie "Failed to checkout $good";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3054)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3055) $result = run_bisect $type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3056)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3057) if ($result ne "good") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3058) fail "Tested BISECT_GOOD [$good] and it failed" and return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3059) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3060) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3061)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3062) # checkout where we started
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3063) run_command "git checkout $head" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3064) dodie "Failed to checkout $head";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3065) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3066)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3067) run_command "git bisect start$start_files" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3068) dodie "could not start bisect";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3069)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3070) if (defined($replay)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3071) run_command "git bisect replay $replay" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3072) dodie "failed to run replay";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3073) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3074)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3075) run_command "git bisect good $good" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3076) dodie "could not set bisect good to $good";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3077)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3078) run_git_bisect "git bisect bad $bad" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3079) dodie "could not set bisect bad to $bad";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3080)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3081) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3082)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3083) if (defined($start)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3084) run_command "git checkout $start" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3085) dodie "failed to checkout $start";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3086) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3087)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3088) my $test;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3089) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3090) $result = run_bisect $type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3091) $test = run_git_bisect "git bisect $result";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3092) print_times;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3093) } while ($test);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3094)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3095) run_command "git bisect log" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3096) dodie "could not capture git bisect log";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3097)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3098) run_command "git bisect reset" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3099) dodie "could not reset git bisect";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3101) doprint "Bad commit was [$bisect_bad_commit]\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3103) success $i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3106) # config_ignore holds the configs that were set (or unset) for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3107) # a good config and we will ignore these configs for the rest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3108) # of a config bisect. These configs stay as they were.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3109) my %config_ignore;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3111) # config_set holds what all configs were set as.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3112) my %config_set;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3114) # config_off holds the set of configs that the bad config had disabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3115) # We need to record them and set them in the .config when running
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3116) # olddefconfig, because olddefconfig keeps the defaults.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3117) my %config_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3119) # config_off_tmp holds a set of configs to turn off for now
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3120) my @config_off_tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3122) # config_list is the set of configs that are being tested
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3123) my %config_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3124) my %null_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3126) my %dependency;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3128) sub assign_configs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3129) my ($hash, $config) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3131) doprint "Reading configs from $config\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3133) open (IN, $config)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3134) or dodie "Failed to read $config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3136) while (<IN>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3137) chomp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3138) if (/^((CONFIG\S*)=.*)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3139) ${$hash}{$2} = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3140) } elsif (/^(# (CONFIG\S*) is not set)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3141) ${$hash}{$2} = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3145) close(IN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3148) sub process_config_ignore {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3149) my ($config) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3151) assign_configs \%config_ignore, $config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3152) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3154) sub get_dependencies {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3155) my ($config) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3157) my $arr = $dependency{$config};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3158) if (!defined($arr)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3159) return ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3162) my @deps = @{$arr};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3164) foreach my $dep (@{$arr}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3165) print "ADD DEP $dep\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3166) @deps = (@deps, get_dependencies $dep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3169) return @deps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3172) sub save_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3173) my ($pc, $file) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3175) my %configs = %{$pc};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3177) doprint "Saving configs into $file\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3179) open(OUT, ">$file") or dodie "Can not write to $file";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3181) foreach my $config (keys %configs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3182) print OUT "$configs{$config}\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3183) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3184) close(OUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3187) sub create_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3188) my ($name, $pc) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3190) doprint "Creating old config from $name configs\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3192) save_config $pc, $output_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3194) make_oldconfig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3197) sub run_config_bisect_test {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3198) my ($type) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3200) my $ret = run_bisect_test $type, "oldconfig";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3202) if ($bisect_manual) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3203) $ret = answer_bisect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3204) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3206) return $ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3207) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3209) sub config_bisect_end {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3210) my ($good, $bad) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3211) my $diffexec = "diff -u";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3213) if (-f "$builddir/scripts/diffconfig") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3214) $diffexec = "$builddir/scripts/diffconfig";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3215) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3216) doprint "\n\n***************************************\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3217) doprint "No more config bisecting possible.\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3218) run_command "$diffexec $good $bad", 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3219) doprint "***************************************\n\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3222) my $pass = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3224) sub run_config_bisect {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3225) my ($good, $bad, $last_result) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3226) my $reset = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3227) my $cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3228) my $ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3230) if (!length($last_result)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3231) $reset = "-r";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3233) run_command "$config_bisect_exec $reset -b $outputdir $good $bad $last_result", 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3235) # config-bisect returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3236) # 0 if there is more to bisect
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3237) # 1 for finding a good config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3238) # 2 if it can not find any more configs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3239) # -1 (255) on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3240) if ($run_command_status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3241) return $run_command_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3244) $ret = run_config_bisect_test $config_bisect_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3245) if ($ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3246) doprint "NEW GOOD CONFIG ($pass)\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3247) system("cp $output_config $tmpdir/good_config.tmp.$pass");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3248) $pass++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3249) # Return 3 for good config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3250) return 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3251) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3252) doprint "NEW BAD CONFIG ($pass)\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3253) system("cp $output_config $tmpdir/bad_config.tmp.$pass");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3254) $pass++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3255) # Return 4 for bad config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3256) return 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3258) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3260) sub config_bisect {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3261) my ($i) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3263) my $good_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3264) my $bad_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3266) my $type = $config_bisect_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3267) my $ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3269) $bad_config = $config_bisect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3271) if (defined($config_bisect_good)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3272) $good_config = $config_bisect_good;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3273) } elsif (defined($minconfig)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3274) $good_config = $minconfig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3275) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3276) doprint "No config specified, checking if defconfig works";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3277) $ret = run_bisect_test $type, "defconfig";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3278) if (!$ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3279) fail "Have no good config to compare with, please set CONFIG_BISECT_GOOD";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3280) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3281) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3282) $good_config = $output_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3283) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3285) if (!defined($config_bisect_exec)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3286) # First check the location that ktest.pl ran
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3287) my @locations = ( "$pwd/config-bisect.pl",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3288) "$dirname/config-bisect.pl",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3289) "$builddir/tools/testing/ktest/config-bisect.pl",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3290) undef );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3291) foreach my $loc (@locations) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3292) doprint "loc = $loc\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3293) $config_bisect_exec = $loc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3294) last if (defined($config_bisect_exec && -x $config_bisect_exec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3295) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3296) if (!defined($config_bisect_exec)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3297) fail "Could not find an executable config-bisect.pl\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3298) " Set CONFIG_BISECT_EXEC to point to config-bisect.pl";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3299) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3300) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3303) # we don't want min configs to cause issues here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3304) doprint "Disabling 'MIN_CONFIG' for this test\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3305) undef $minconfig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3307) my %good_configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3308) my %bad_configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3309) my %tmp_configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3311) if (-f "$tmpdir/good_config.tmp" || -f "$tmpdir/bad_config.tmp") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3312) if (read_yn "Interrupted config-bisect. Continue (n - will start new)?") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3313) if (-f "$tmpdir/good_config.tmp") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3314) $good_config = "$tmpdir/good_config.tmp";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3315) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3316) $good_config = "$tmpdir/good_config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3317) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3318) if (-f "$tmpdir/bad_config.tmp") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3319) $bad_config = "$tmpdir/bad_config.tmp";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3320) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3321) $bad_config = "$tmpdir/bad_config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3322) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3323) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3324) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3325) doprint "Run good configs through make oldconfig\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3326) assign_configs \%tmp_configs, $good_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3327) create_config "$good_config", \%tmp_configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3328) $good_config = "$tmpdir/good_config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3329) system("cp $output_config $good_config") == 0 or dodie "cp good config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3331) doprint "Run bad configs through make oldconfig\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3332) assign_configs \%tmp_configs, $bad_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3333) create_config "$bad_config", \%tmp_configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3334) $bad_config = "$tmpdir/bad_config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3335) system("cp $output_config $bad_config") == 0 or dodie "cp bad config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3337) if (defined($config_bisect_check) && $config_bisect_check ne "0") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3338) if ($config_bisect_check ne "good") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3339) doprint "Testing bad config\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3341) $ret = run_bisect_test $type, "useconfig:$bad_config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3342) if ($ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3343) fail "Bad config succeeded when expected to fail!";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3344) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3345) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3346) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3347) if ($config_bisect_check ne "bad") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3348) doprint "Testing good config\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3350) $ret = run_bisect_test $type, "useconfig:$good_config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3351) if (!$ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3352) fail "Good config failed when expected to succeed!";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3353) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3354) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3355) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3356) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3358) my $last_run = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3360) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3361) $ret = run_config_bisect $good_config, $bad_config, $last_run;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3362) if ($ret == 3) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3363) $last_run = "good";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3364) } elsif ($ret == 4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3365) $last_run = "bad";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3366) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3367) print_times;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3368) } while ($ret == 3 || $ret == 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3370) if ($ret == 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3371) config_bisect_end "$good_config.tmp", "$bad_config.tmp";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3372) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3374) return $ret if ($ret < 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3376) success $i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3377) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3379) sub patchcheck_reboot {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3380) doprint "Reboot and sleep $patchcheck_sleep_time seconds\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3381) reboot_to_good $patchcheck_sleep_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3382) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3384) sub patchcheck {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3385) my ($i) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3387) dodie "PATCHCHECK_START[$i] not defined\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3388) if (!defined($patchcheck_start));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3389) dodie "PATCHCHECK_TYPE[$i] not defined\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3390) if (!defined($patchcheck_type));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3392) my $start = $patchcheck_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3394) my $cherry = $patchcheck_cherry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3395) if (!defined($cherry)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3396) $cherry = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3397) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3398)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3399) my $end = "HEAD";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3400) if (defined($patchcheck_end)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3401) $end = $patchcheck_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3402) } elsif ($cherry) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3403) dodie "PATCHCHECK_END must be defined with PATCHCHECK_CHERRY\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3404) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3406) # Get the true sha1's since we can use things like HEAD~3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3407) $start = get_sha1($start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3408) $end = get_sha1($end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3409)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3410) my $type = $patchcheck_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3412) # Can't have a test without having a test to run
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3413) if ($type eq "test" && !defined($run_test)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3414) $type = "boot";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3415) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3417) if ($cherry) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3418) open (IN, "git cherry -v $start $end|") or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3419) dodie "could not get git list";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3420) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3421) open (IN, "git log --pretty=oneline $end|") or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3422) dodie "could not get git list";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3423) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3425) my @list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3427) while (<IN>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3428) chomp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3429) # git cherry adds a '+' we want to remove
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3430) s/^\+ //;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3431) $list[$#list+1] = $_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3432) last if (/^$start/);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3433) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3434) close(IN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3436) if (!$cherry) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3437) if ($list[$#list] !~ /^$start/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3438) fail "SHA1 $start not found";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3439) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3440)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3441) # go backwards in the list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3442) @list = reverse @list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3443) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3445) doprint("Going to test the following commits:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3446) foreach my $l (@list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3447) doprint "$l\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3448) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3450) my $save_clean = $noclean;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3451) my %ignored_warnings;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3452)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3453) if (defined($ignore_warnings)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3454) foreach my $sha1 (split /\s+/, $ignore_warnings) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3455) $ignored_warnings{$sha1} = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3456) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3457) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3458)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3459) $in_patchcheck = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3460) foreach my $item (@list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3461) my $sha1 = $item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3462) $sha1 =~ s/^([[:xdigit:]]+).*/$1/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3464) doprint "\nProcessing commit \"$item\"\n\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3466) run_command "git checkout $sha1" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3467) dodie "Failed to checkout $sha1";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3469) # only clean on the first and last patch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3470) if ($item eq $list[0] ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3471) $item eq $list[$#list]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3472) $noclean = $save_clean;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3473) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3474) $noclean = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3475) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3476)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3477) if (defined($minconfig)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3478) build "useconfig:$minconfig" or return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3479) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3480) # ?? no config to use?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3481) build "oldconfig" or return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3482) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3483)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3484) # No need to do per patch checking if warnings file exists
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3485) if (!defined($warnings_file) && !defined($ignored_warnings{$sha1})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3486) check_patch_buildlog $sha1 or return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3487) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3489) check_buildlog or return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3491) next if ($type eq "build");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3493) my $failed = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3495) start_monitor_and_install or $failed = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3497) if (!$failed && $type ne "boot"){
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3498) do_run_test or $failed = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3499) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3500) end_monitor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3501) if ($failed) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3502) print_times;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3503) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3504) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3505) patchcheck_reboot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3506) print_times;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3507) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3508) $in_patchcheck = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3509) success $i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3510)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3511) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3512) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3514) my %depends;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3515) my %depcount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3516) my $iflevel = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3517) my @ifdeps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3519) # prevent recursion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3520) my %read_kconfigs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3522) sub add_dep {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3523) # $config depends on $dep
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3524) my ($config, $dep) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3525)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3526) if (defined($depends{$config})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3527) $depends{$config} .= " " . $dep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3528) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3529) $depends{$config} = $dep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3530) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3532) # record the number of configs depending on $dep
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3533) if (defined $depcount{$dep}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3534) $depcount{$dep}++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3535) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3536) $depcount{$dep} = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3537) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3538) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3539)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3540) # taken from streamline_config.pl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3541) sub read_kconfig {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3542) my ($kconfig) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3544) my $state = "NONE";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3545) my $config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3546) my @kconfigs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3547)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3548) my $cont = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3549) my $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3551)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3552) if (! -f $kconfig) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3553) doprint "file $kconfig does not exist, skipping\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3554) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3555) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3556)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3557) open(KIN, "$kconfig")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3558) or dodie "Can't open $kconfig";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3559) while (<KIN>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3560) chomp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3561)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3562) # Make sure that lines ending with \ continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3563) if ($cont) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3564) $_ = $line . " " . $_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3565) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3567) if (s/\\$//) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3568) $cont = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3569) $line = $_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3570) next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3571) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3573) $cont = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3574)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3575) # collect any Kconfig sources
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3576) if (/^source\s*"(.*)"/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3577) $kconfigs[$#kconfigs+1] = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3578) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3580) # configs found
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3581) if (/^\s*(menu)?config\s+(\S+)\s*$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3582) $state = "NEW";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3583) $config = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3585) for (my $i = 0; $i < $iflevel; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3586) add_dep $config, $ifdeps[$i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3587) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3589) # collect the depends for the config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3590) } elsif ($state eq "NEW" && /^\s*depends\s+on\s+(.*)$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3592) add_dep $config, $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3593)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3594) # Get the configs that select this config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3595) } elsif ($state eq "NEW" && /^\s*select\s+(\S+)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3596)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3597) # selected by depends on config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3598) add_dep $1, $config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3599)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3600) # Check for if statements
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3601) } elsif (/^if\s+(.*\S)\s*$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3602) my $deps = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3603) # remove beginning and ending non text
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3604) $deps =~ s/^[^a-zA-Z0-9_]*//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3605) $deps =~ s/[^a-zA-Z0-9_]*$//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3606)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3607) my @deps = split /[^a-zA-Z0-9_]+/, $deps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3608)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3609) $ifdeps[$iflevel++] = join ':', @deps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3610)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3611) } elsif (/^endif/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3612)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3613) $iflevel-- if ($iflevel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3614)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3615) # stop on "help"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3616) } elsif (/^\s*help\s*$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3617) $state = "NONE";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3618) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3619) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3620) close(KIN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3621)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3622) # read in any configs that were found.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3623) foreach $kconfig (@kconfigs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3624) if (!defined($read_kconfigs{$kconfig})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3625) $read_kconfigs{$kconfig} = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3626) read_kconfig("$builddir/$kconfig");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3627) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3628) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3629) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3630)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3631) sub read_depends {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3632) # find out which arch this is by the kconfig file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3633) open (IN, $output_config)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3634) or dodie "Failed to read $output_config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3635) my $arch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3636) while (<IN>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3637) if (m,Linux/(\S+)\s+\S+\s+Kernel Configuration,) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3638) $arch = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3639) last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3640) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3641) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3642) close IN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3643)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3644) if (!defined($arch)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3645) doprint "Could not find arch from config file\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3646) doprint "no dependencies used\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3647) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3648) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3649)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3650) # arch is really the subarch, we need to know
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3651) # what directory to look at.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3652) if ($arch eq "i386" || $arch eq "x86_64") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3653) $arch = "x86";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3654) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3655)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3656) my $kconfig = "$builddir/arch/$arch/Kconfig";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3657)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3658) if (! -f $kconfig && $arch =~ /\d$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3659) my $orig = $arch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3660) # some subarchs have numbers, truncate them
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3661) $arch =~ s/\d*$//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3662) $kconfig = "$builddir/arch/$arch/Kconfig";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3663) if (! -f $kconfig) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3664) doprint "No idea what arch dir $orig is for\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3665) doprint "no dependencies used\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3666) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3667) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3668) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3669)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3670) read_kconfig($kconfig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3671) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3672)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3673) sub make_new_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3674) my @configs = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3675)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3676) open (OUT, ">$output_config")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3677) or dodie "Failed to write $output_config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3678)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3679) foreach my $config (@configs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3680) print OUT "$config\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3681) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3682) close OUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3683) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3684)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3685) sub chomp_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3686) my ($config) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3687)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3688) $config =~ s/CONFIG_//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3689)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3690) return $config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3691) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3692)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3693) sub get_depends {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3694) my ($dep) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3695)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3696) my $kconfig = chomp_config $dep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3697)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3698) $dep = $depends{"$kconfig"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3699)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3700) # the dep string we have saves the dependencies as they
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3701) # were found, including expressions like ! && ||. We
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3702) # want to split this out into just an array of configs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3703)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3704) my $valid = "A-Za-z_0-9";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3705)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3706) my @configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3707)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3708) while ($dep =~ /[$valid]/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3709)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3710) if ($dep =~ /^[^$valid]*([$valid]+)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3711) my $conf = "CONFIG_" . $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3712)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3713) $configs[$#configs + 1] = $conf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3714)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3715) $dep =~ s/^[^$valid]*[$valid]+//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3716) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3717) dodie "this should never happen";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3718) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3719) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3720)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3721) return @configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3722) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3723)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3724) my %min_configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3725) my %keep_configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3726) my %save_configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3727) my %processed_configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3728) my %nochange_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3729)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3730) sub test_this_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3731) my ($config) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3732)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3733) my $found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3734)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3735) # if we already processed this config, skip it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3736) if (defined($processed_configs{$config})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3737) return undef;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3738) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3739) $processed_configs{$config} = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3740)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3741) # if this config failed during this round, skip it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3742) if (defined($nochange_config{$config})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3743) return undef;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3744) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3745)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3746) my $kconfig = chomp_config $config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3747)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3748) # Test dependencies first
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3749) if (defined($depends{"$kconfig"})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3750) my @parents = get_depends $config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3751) foreach my $parent (@parents) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3752) # if the parent is in the min config, check it first
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3753) next if (!defined($min_configs{$parent}));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3754) $found = test_this_config($parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3755) if (defined($found)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3756) return $found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3757) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3758) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3759) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3761) # Remove this config from the list of configs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3762) # do a make olddefconfig and then read the resulting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3763) # .config to make sure it is missing the config that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3764) # we had before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3765) my %configs = %min_configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3766) delete $configs{$config};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3767) make_new_config ((values %configs), (values %keep_configs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3768) make_oldconfig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3769) undef %configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3770) assign_configs \%configs, $output_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3771)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3772) if (!defined($configs{$config}) || $configs{$config} =~ /^#/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3773) return $config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3774) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3775)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3776) doprint "disabling config $config did not change .config\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3777)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3778) $nochange_config{$config} = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3779)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3780) return undef;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3781) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3782)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3783) sub make_min_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3784) my ($i) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3785)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3786) my $type = $minconfig_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3787) if ($type ne "boot" && $type ne "test") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3788) fail "Invalid MIN_CONFIG_TYPE '$minconfig_type'\n" .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3789) " make_min_config works only with 'boot' and 'test'\n" and return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3790) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3791)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3792) if (!defined($output_minconfig)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3793) fail "OUTPUT_MIN_CONFIG not defined" and return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3794) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3795)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3796) # If output_minconfig exists, and the start_minconfig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3797) # came from min_config, than ask if we should use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3798) # that instead.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3799) if (-f $output_minconfig && !$start_minconfig_defined) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3800) print "$output_minconfig exists\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3801) if (!defined($use_output_minconfig)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3802) if (read_yn " Use it as minconfig?") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3803) $start_minconfig = $output_minconfig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3804) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3805) } elsif ($use_output_minconfig > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3806) doprint "Using $output_minconfig as MIN_CONFIG\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3807) $start_minconfig = $output_minconfig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3808) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3809) doprint "Set to still use MIN_CONFIG as starting point\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3810) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3811) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3812)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3813) if (!defined($start_minconfig)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3814) fail "START_MIN_CONFIG or MIN_CONFIG not defined" and return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3815) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3816)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3817) my $temp_config = "$tmpdir/temp_config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3818)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3819) # First things first. We build an allnoconfig to find
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3820) # out what the defaults are that we can't touch.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3821) # Some are selections, but we really can't handle selections.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3822)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3823) my $save_minconfig = $minconfig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3824) undef $minconfig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3825)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3826) run_command "$make allnoconfig" or return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3827)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3828) read_depends;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3829)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3830) process_config_ignore $output_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3831)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3832) undef %save_configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3833) undef %min_configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3834)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3835) if (defined($ignore_config)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3836) # make sure the file exists
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3837) `touch $ignore_config`;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3838) assign_configs \%save_configs, $ignore_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3839) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3840)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3841) %keep_configs = %save_configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3842)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3843) doprint "Load initial configs from $start_minconfig\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3844)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3845) # Look at the current min configs, and save off all the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3846) # ones that were set via the allnoconfig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3847) assign_configs \%min_configs, $start_minconfig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3848)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3849) my @config_keys = keys %min_configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3850)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3851) # All configs need a depcount
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3852) foreach my $config (@config_keys) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3853) my $kconfig = chomp_config $config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3854) if (!defined $depcount{$kconfig}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3855) $depcount{$kconfig} = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3856) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3857) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3859) # Remove anything that was set by the make allnoconfig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3860) # we shouldn't need them as they get set for us anyway.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3861) foreach my $config (@config_keys) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3862) # Remove anything in the ignore_config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3863) if (defined($keep_configs{$config})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3864) my $file = $ignore_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3865) $file =~ s,.*/(.*?)$,$1,;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3866) doprint "$config set by $file ... ignored\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3867) delete $min_configs{$config};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3868) next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3869) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3870) # But make sure the settings are the same. If a min config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3871) # sets a selection, we do not want to get rid of it if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3872) # it is not the same as what we have. Just move it into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3873) # the keep configs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3874) if (defined($config_ignore{$config})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3875) if ($config_ignore{$config} ne $min_configs{$config}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3876) doprint "$config is in allnoconfig as '$config_ignore{$config}'";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3877) doprint " but it is '$min_configs{$config}' in minconfig .. keeping\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3878) $keep_configs{$config} = $min_configs{$config};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3879) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3880) doprint "$config set by allnoconfig ... ignored\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3881) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3882) delete $min_configs{$config};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3883) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3884) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3885)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3886) my $done = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3887) my $take_two = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3888)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3889) while (!$done) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3890)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3891) my $config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3892) my $found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3893)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3894) # Now disable each config one by one and do a make oldconfig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3895) # till we find a config that changes our list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3896)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3897) my @test_configs = keys %min_configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3898)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3899) # Sort keys by who is most dependent on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3900) @test_configs = sort { $depcount{chomp_config($b)} <=> $depcount{chomp_config($a)} }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3901) @test_configs ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3902)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3903) # Put configs that did not modify the config at the end.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3904) my $reset = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3905) for (my $i = 0; $i < $#test_configs; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3906) if (!defined($nochange_config{$test_configs[0]})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3907) $reset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3908) last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3909) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3910) # This config didn't change the .config last time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3911) # Place it at the end
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3912) my $config = shift @test_configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3913) push @test_configs, $config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3914) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3915)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3916) # if every test config has failed to modify the .config file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3917) # in the past, then reset and start over.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3918) if ($reset) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3919) undef %nochange_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3920) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3921)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3922) undef %processed_configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3923)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3924) foreach my $config (@test_configs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3925)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3926) $found = test_this_config $config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3927)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3928) last if (defined($found));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3929)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3930) # oh well, try another config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3931) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3932)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3933) if (!defined($found)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3934) # we could have failed due to the nochange_config hash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3935) # reset and try again
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3936) if (!$take_two) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3937) undef %nochange_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3938) $take_two = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3939) next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3940) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3941) doprint "No more configs found that we can disable\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3942) $done = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3943) last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3944) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3945) $take_two = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3946)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3947) $config = $found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3948)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3949) doprint "Test with $config disabled\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3950)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3951) # set in_bisect to keep build and monitor from dieing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3952) $in_bisect = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3953)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3954) my $failed = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3955) build "oldconfig" or $failed = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3956) if (!$failed) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3957) start_monitor_and_install or $failed = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3958)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3959) if ($type eq "test" && !$failed) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3960) do_run_test or $failed = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3961) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3962)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3963) end_monitor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3964) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3965)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3966) $in_bisect = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3967)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3968) if ($failed) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3969) doprint "$min_configs{$config} is needed to boot the box... keeping\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3970) # this config is needed, add it to the ignore list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3971) $keep_configs{$config} = $min_configs{$config};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3972) $save_configs{$config} = $min_configs{$config};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3973) delete $min_configs{$config};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3974)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3975) # update new ignore configs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3976) if (defined($ignore_config)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3977) open (OUT, ">$temp_config")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3978) or dodie "Can't write to $temp_config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3979) foreach my $config (keys %save_configs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3980) print OUT "$save_configs{$config}\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3981) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3982) close OUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3983) run_command "mv $temp_config $ignore_config" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3984) dodie "failed to copy update to $ignore_config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3985) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3986)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3987) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3988) # We booted without this config, remove it from the minconfigs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3989) doprint "$config is not needed, disabling\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3990)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3991) delete $min_configs{$config};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3992)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3993) # Also disable anything that is not enabled in this config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3994) my %configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3995) assign_configs \%configs, $output_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3996) my @config_keys = keys %min_configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3997) foreach my $config (@config_keys) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3998) if (!defined($configs{$config})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3999) doprint "$config is not set, disabling\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4000) delete $min_configs{$config};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4001) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4002) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4003)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4004) # Save off all the current mandatory configs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4005) open (OUT, ">$temp_config")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4006) or dodie "Can't write to $temp_config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4007) foreach my $config (keys %keep_configs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4008) print OUT "$keep_configs{$config}\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4009) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4010) foreach my $config (keys %min_configs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4011) print OUT "$min_configs{$config}\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4012) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4013) close OUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4014)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4015) run_command "mv $temp_config $output_minconfig" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4016) dodie "failed to copy update to $output_minconfig";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4017) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4018)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4019) doprint "Reboot and wait $sleep_time seconds\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4020) reboot_to_good $sleep_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4021) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4022)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4023) success $i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4024) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4025) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4026)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4027) sub make_warnings_file {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4028) my ($i) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4029)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4030) if (!defined($warnings_file)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4031) dodie "Must define WARNINGS_FILE for make_warnings_file test";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4032) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4033)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4034) if ($build_type eq "nobuild") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4035) dodie "BUILD_TYPE can not be 'nobuild' for make_warnings_file test";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4036) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4037)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4038) build $build_type or dodie "Failed to build";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4039)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4040) open(OUT, ">$warnings_file") or dodie "Can't create $warnings_file";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4041)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4042) open(IN, $buildlog) or dodie "Can't open $buildlog";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4043) while (<IN>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4044)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4045) # Some compilers use UTF-8 extended for quotes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4046) # for distcc heterogeneous systems, this causes issues
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4047) s/$utf8_quote/'/g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4048)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4049) if (/$check_build_re/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4050) print OUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4051) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4052) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4053) close(IN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4054)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4055) close(OUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4056)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4057) success $i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4058) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4059)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4060) $#ARGV < 1 or die "ktest.pl version: $VERSION\n usage: ktest.pl [config-file]\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4061)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4062) if ($#ARGV == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4063) $ktest_config = $ARGV[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4064) if (! -f $ktest_config) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4065) print "$ktest_config does not exist.\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4066) if (!read_yn "Create it?") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4067) exit 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4068) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4069) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4070) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4071)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4072) if (! -f $ktest_config) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4073) $newconfig = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4074) get_test_case;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4075) open(OUT, ">$ktest_config") or die "Can not create $ktest_config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4076) print OUT << "EOF"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4077) # Generated by ktest.pl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4078) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4079)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4080) # PWD is a ktest.pl variable that will result in the process working
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4081) # directory that ktest.pl is executed in.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4082)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4083) # THIS_DIR is automatically assigned the PWD of the path that generated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4084) # the config file. It is best to use this variable when assigning other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4085) # directory paths within this directory. This allows you to easily
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4086) # move the test cases to other locations or to other machines.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4087) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4088) THIS_DIR := $variable{"PWD"}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4089)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4090) # Define each test with TEST_START
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4091) # The config options below it will override the defaults
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4092) TEST_START
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4093) TEST_TYPE = $default{"TEST_TYPE"}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4094)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4095) DEFAULTS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4096) EOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4097) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4098) close(OUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4099) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4100) read_config $ktest_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4102) if (defined($opt{"LOG_FILE"})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4103) $opt{"LOG_FILE"} = eval_option("LOG_FILE", $opt{"LOG_FILE"}, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4106) # Append any configs entered in manually to the config file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4107) my @new_configs = keys %entered_configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4108) if ($#new_configs >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4109) print "\nAppending entered in configs to $ktest_config\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4110) open(OUT, ">>$ktest_config") or die "Can not append to $ktest_config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4111) foreach my $config (@new_configs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4112) print OUT "$config = $entered_configs{$config}\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4113) $opt{$config} = process_variables($entered_configs{$config});
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4117) if (defined($opt{"LOG_FILE"})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4118) if ($opt{"CLEAR_LOG"}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4119) unlink $opt{"LOG_FILE"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4121) open(LOG, ">> $opt{LOG_FILE}") or die "Can't write to $opt{LOG_FILE}";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4122) LOG->autoflush(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4123) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4125) doprint "\n\nSTARTING AUTOMATED TESTS\n\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4127) for (my $i = 0, my $repeat = 1; $i <= $opt{"NUM_TESTS"}; $i += $repeat) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4129) if (!$i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4130) doprint "DEFAULT OPTIONS:\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4131) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4132) doprint "\nTEST $i OPTIONS";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4133) if (defined($repeat_tests{$i})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4134) $repeat = $repeat_tests{$i};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4135) doprint " ITERATE $repeat";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4136) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4137) doprint "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4140) foreach my $option (sort keys %opt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4142) if ($option =~ /\[(\d+)\]$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4143) next if ($i != $1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4144) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4145) next if ($i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4148) doprint "$option = $opt{$option}\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4152) sub option_defined {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4153) my ($option) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4155) if (defined($opt{$option}) && $opt{$option} !~ /^\s*$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4156) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4159) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4162) sub __set_test_option {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4163) my ($name, $i) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4165) my $option = "$name\[$i\]";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4167) if (option_defined($option)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4168) return $opt{$option};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4171) foreach my $test (keys %repeat_tests) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4172) if ($i >= $test &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4173) $i < $test + $repeat_tests{$test}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4174) $option = "$name\[$test\]";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4175) if (option_defined($option)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4176) return $opt{$option};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4177) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4181) if (option_defined($name)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4182) return $opt{$name};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4183) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4185) return undef;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4186) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4188) sub set_test_option {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4189) my ($name, $i) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4191) my $option = __set_test_option($name, $i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4192) return $option if (!defined($option));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4194) return eval_option($name, $option, $i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4197) sub find_mailer {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4198) my ($mailer) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4200) my @paths = split /:/, $ENV{PATH};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4202) # sendmail is usually in /usr/sbin
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4203) $paths[$#paths + 1] = "/usr/sbin";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4205) foreach my $path (@paths) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4206) if (-x "$path/$mailer") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4207) return $path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4209) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4211) return undef;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4212) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4214) sub do_send_mail {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4215) my ($subject, $message, $file) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4217) if (!defined($mail_path)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4218) # find the mailer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4219) $mail_path = find_mailer $mailer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4220) if (!defined($mail_path)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4221) die "\nCan not find $mailer in PATH\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4222) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4225) my $header_file = "$tmpdir/header";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4226) open (HEAD, ">$header_file") or die "Can not create $header_file\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4227) print HEAD "To: $mailto\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4228) print HEAD "Subject: $subject\n\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4229) print HEAD "$message\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4230) close HEAD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4232) if (!defined($mail_command)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4233) if ($mailer eq "mail" || $mailer eq "mailx") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4234) $mail_command = "cat \$HEADER_FILE \$BODY_FILE | \$MAIL_PATH/\$MAILER -s \'\$SUBJECT\' \$MAILTO";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4235) } elsif ($mailer eq "sendmail" ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4236) $mail_command = "cat \$HEADER_FILE \$BODY_FILE | \$MAIL_PATH/\$MAILER -t \$MAILTO";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4237) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4238) die "\nYour mailer: $mailer is not supported.\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4240) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4242) if (defined($file)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4243) $mail_command =~ s/\$BODY_FILE/$file/g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4244) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4245) $mail_command =~ s/\$BODY_FILE//g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4246) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4248) $mail_command =~ s/\$HEADER_FILE/$header_file/g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4249) $mail_command =~ s/\$MAILER/$mailer/g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4250) $mail_command =~ s/\$MAIL_PATH/$mail_path/g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4251) $mail_command =~ s/\$MAILTO/$mailto/g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4252) $mail_command =~ s/\$SUBJECT/$subject/g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4253) $mail_command =~ s/\$MESSAGE/$message/g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4255) my $ret = run_command $mail_command;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4256) if (!$ret && defined($file)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4257) # try again without the file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4258) $message .= "\n\n*** FAILED TO SEND LOG ***\n\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4259) do_send_email($subject, $message);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4261) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4263) sub send_email {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4265) if (defined($mailto)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4266) if (!defined($mailer)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4267) doprint "No email sent: email or mailer not specified in config.\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4268) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4269) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4270) do_send_mail @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4271) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4272) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4274) sub cancel_test {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4275) if ($email_when_canceled) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4276) my $name = get_test_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4277) send_email("KTEST: Your [$name] test was cancelled",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4278) "Your test started at $script_start_time was cancelled: sig int");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4279) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4280) die "\nCaught Sig Int, test interrupted: $!\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4281) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4283) $SIG{INT} = qw(cancel_test);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4285) # First we need to do is the builds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4286) for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4288) # Do not reboot on failing test options
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4289) $no_reboot = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4290) $reboot_success = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4292) $have_version = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4294) $iteration = $i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4296) $build_time = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4297) $install_time = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4298) $reboot_time = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4299) $test_time = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4301) undef %force_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4303) my $makecmd = set_test_option("MAKE_CMD", $i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4305) $outputdir = set_test_option("OUTPUT_DIR", $i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4306) $builddir = set_test_option("BUILD_DIR", $i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4308) chdir $builddir || dodie "can't change directory to $builddir";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4310) if (!-d $outputdir) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4311) mkpath($outputdir) or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4312) dodie "can't create $outputdir";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4313) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4315) $make = "$makecmd O=$outputdir";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4317) # Load all the options into their mapped variable names
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4318) foreach my $opt (keys %option_map) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4319) ${$option_map{$opt}} = set_test_option($opt, $i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4320) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4322) $start_minconfig_defined = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4324) # The first test may override the PRE_KTEST option
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4325) if ($i == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4326) if (defined($pre_ktest)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4327) doprint "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4328) run_command $pre_ktest;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4329) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4330) if ($email_when_started) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4331) my $name = get_test_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4332) send_email("KTEST: Your [$name] test was started",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4333) "Your test was started on $script_start_time");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4334) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4335) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4337) # Any test can override the POST_KTEST option
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4338) # The last test takes precedence.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4339) if (defined($post_ktest)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4340) $final_post_ktest = $post_ktest;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4341) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4343) if (!defined($start_minconfig)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4344) $start_minconfig_defined = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4345) $start_minconfig = $minconfig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4346) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4348) if (!-d $tmpdir) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4349) mkpath($tmpdir) or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4350) dodie "can't create $tmpdir";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4351) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4353) $ENV{"SSH_USER"} = $ssh_user;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4354) $ENV{"MACHINE"} = $machine;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4355)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4356) $buildlog = "$tmpdir/buildlog-$machine";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4357) $testlog = "$tmpdir/testlog-$machine";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4358) $dmesg = "$tmpdir/dmesg-$machine";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4359) $output_config = "$outputdir/.config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4361) if (!$buildonly) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4362) $target = "$ssh_user\@$machine";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4363) if (($reboot_type eq "grub") or ($reboot_type eq "grub2bls")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4364) dodie "GRUB_MENU not defined" if (!defined($grub_menu));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4365) } elsif ($reboot_type eq "grub2") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4366) dodie "GRUB_MENU not defined" if (!defined($grub_menu));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4367) dodie "GRUB_FILE not defined" if (!defined($grub_file));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4368) } elsif ($reboot_type eq "syslinux") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4369) dodie "SYSLINUX_LABEL not defined" if (!defined($syslinux_label));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4370) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4371) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4373) my $run_type = $build_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4374) if ($test_type eq "patchcheck") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4375) $run_type = $patchcheck_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4376) } elsif ($test_type eq "bisect") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4377) $run_type = $bisect_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4378) } elsif ($test_type eq "config_bisect") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4379) $run_type = $config_bisect_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4380) } elsif ($test_type eq "make_min_config") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4381) $run_type = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4382) } elsif ($test_type eq "make_warnings_file") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4383) $run_type = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4384) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4385)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4386) # mistake in config file?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4387) if (!defined($run_type)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4388) $run_type = "ERROR";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4389) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4391) my $installme = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4392) $installme = " no_install" if ($no_install);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4394) my $name = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4395)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4396) if (defined($test_name)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4397) $name = " ($test_name)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4398) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4400) doprint "\n\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4401)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4402) if (defined($opt{"LOG_FILE"})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4403) $test_log_start = tell(LOG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4404) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4406) doprint "RUNNING TEST $i of $opt{NUM_TESTS}$name with option $test_type $run_type$installme\n\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4408) if (defined($pre_test)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4409) my $ret = run_command $pre_test;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4410) if (!$ret && defined($pre_test_die) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4411) $pre_test_die) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4412) dodie "failed to pre_test\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4413) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4414) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4416) unlink $dmesg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4417) unlink $buildlog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4418) unlink $testlog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4420) if (defined($addconfig)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4421) my $min = $minconfig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4422) if (!defined($minconfig)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4423) $min = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4424) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4425) run_command "cat $addconfig $min > $tmpdir/add_config" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4426) dodie "Failed to create temp config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4427) $minconfig = "$tmpdir/add_config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4428) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4429)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4430) if (defined($checkout)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4431) run_command "git checkout $checkout" or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4432) dodie "failed to checkout $checkout";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4433) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4435) $no_reboot = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4437) # A test may opt to not reboot the box
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4438) if ($reboot_on_success) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4439) $reboot_success = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4440) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4442) if ($test_type eq "bisect") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4443) bisect $i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4444) next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4445) } elsif ($test_type eq "config_bisect") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4446) config_bisect $i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4447) next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4448) } elsif ($test_type eq "patchcheck") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4449) patchcheck $i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4450) next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4451) } elsif ($test_type eq "make_min_config") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4452) make_min_config $i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4453) next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4454) } elsif ($test_type eq "make_warnings_file") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4455) $no_reboot = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4456) make_warnings_file $i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4457) next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4458) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4460) if ($build_type ne "nobuild") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4461) build $build_type or next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4462) check_buildlog or next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4463) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4464)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4465) if ($test_type eq "install") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4466) get_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4467) install;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4468) success $i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4469) next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4470) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4472) if ($test_type ne "build") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4473) my $failed = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4474) start_monitor_and_install or $failed = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4476) if (!$failed && $test_type ne "boot" && defined($run_test)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4477) do_run_test or $failed = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4478) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4479) end_monitor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4480) if ($failed) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4481) print_times;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4482) next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4483) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4484) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4486) print_times;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4487)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4488) success $i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4489) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4491) if (defined($final_post_ktest)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4493) my $cp_final_post_ktest = eval_kernel_version $final_post_ktest;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4494) run_command $cp_final_post_ktest;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4495) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4497) if ($opt{"POWEROFF_ON_SUCCESS"}) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4498) halt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4499) } elsif ($opt{"REBOOT_ON_SUCCESS"} && !do_not_reboot && $reboot_success) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4500) reboot_to_good;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4501) } elsif (defined($switch_to_good)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4502) # still need to get to the good kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4503) run_command $switch_to_good;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4504) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4506)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4507) doprint "\n $successes of $opt{NUM_TESTS} tests were successful\n\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4508)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4509) if ($email_when_finished) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4510) send_email("KTEST: Your test has finished!",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4511) "$successes of $opt{NUM_TESTS} tests started at $script_start_time were successful!");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4512) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4514) if (defined($opt{"LOG_FILE"})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4515) print "\n See $opt{LOG_FILE} for the record of results.\n\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4516) close LOG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4517) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4519) exit 0;