ktest: Add native support for syslinux boot loader
[profile/ivi/kernel-adaptation-intel-automotive.git] / tools / testing / ktest / ktest.pl
index f4b8f96..067337b 100755 (executable)
@@ -54,6 +54,8 @@ my %default = (
     "STOP_TEST_AFTER"          => 600,
     "MAX_MONITOR_WAIT"         => 1800,
     "GRUB_REBOOT"              => "grub2-reboot",
+    "SYSLINUX"                 => "extlinux",
+    "SYSLINUX_PATH"            => "/boot/extlinux",
 
 # required, and we will ask users if they don't have them but we keep the default
 # value something that is common.
@@ -109,6 +111,9 @@ my $grub_menu;
 my $grub_file;
 my $grub_number;
 my $grub_reboot;
+my $syslinux;
+my $syslinux_path;
+my $syslinux_label;
 my $target;
 my $make;
 my $pre_install;
@@ -237,6 +242,9 @@ my %option_map = (
     "GRUB_MENU"                        => \$grub_menu,
     "GRUB_FILE"                        => \$grub_file,
     "GRUB_REBOOT"              => \$grub_reboot,
+    "SYSLINUX"                 => \$syslinux,
+    "SYSLINUX_PATH"            => \$syslinux_path,
+    "SYSLINUX_LABEL"           => \$syslinux_label,
     "PRE_INSTALL"              => \$pre_install,
     "POST_INSTALL"             => \$post_install,
     "NO_INSTALL"               => \$no_install,
@@ -373,7 +381,7 @@ EOF
     ;
 $config_help{"REBOOT_TYPE"} = << "EOF"
  Way to reboot the box to the test kernel.
- Only valid options so far are "grub", "grub2", and "script".
+ Only valid options so far are "grub", "grub2", "syslinux", and "script".
 
  If you specify grub, it will assume grub version 1
  and will search in /boot/grub/menu.lst for the title \$GRUB_MENU
@@ -386,6 +394,11 @@ $config_help{"REBOOT_TYPE"} = << "EOF"
 
  If you specify grub2, then you also need to specify both \$GRUB_MENU
  and \$GRUB_FILE.
+
+ If you specify syslinux, then you may use SYSLINUX to define the syslinux
+ command (defaults to extlinux), and SYSLINUX_PATH to specify the path to
+ the syslinux install (defaults to /boot/extlinux). But you have to specify
+ SYSLINUX_LABEL to define the label to boot to for the test kernel.
 EOF
     ;
 $config_help{"GRUB_MENU"} = << "EOF"
@@ -414,6 +427,11 @@ $config_help{"GRUB_FILE"} = << "EOF"
  here. Use something like /boot/grub2/grub.cfg to search.
 EOF
     ;
+$config_help{"SYSLINUX_LABEL"} = << "EOF"
+ If syslinux is used, the label that boots the target kernel must
+ be specified with SYSLINUX_LABEL.
+EOF
+    ;
 $config_help{"REBOOT_SCRIPT"} = << "EOF"
  A script to reboot the target into the test kernel
  (Only mandatory if REBOOT_TYPE = script)
@@ -545,6 +563,10 @@ sub get_ktest_configs {
        get_ktest_config("GRUB_MENU");
        get_ktest_config("GRUB_FILE");
     }
+
+    if ($rtype eq "syslinux") {
+       get_ktest_config("SYSLINUX_LABEL");
+    }
 }
 
 sub process_variables {
@@ -1589,6 +1611,8 @@ sub reboot_to {
        run_ssh "'(echo \"savedefault --default=$grub_number --once\" | grub --batch)'";
     } elsif ($reboot_type eq "grub2") {
        run_ssh "$grub_reboot $grub_number";
+    } elsif ($reboot_type eq "syslinux") {
+       run_ssh "$syslinux --once \\\"$syslinux_label\\\" $syslinux_path";
     } elsif (defined $reboot_script) {
        run_command "$reboot_script";
     }
@@ -3768,6 +3792,8 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
        } elsif ($reboot_type eq "grub2") {
            dodie "GRUB_MENU not defined" if (!defined($grub_menu));
            dodie "GRUB_FILE not defined" if (!defined($grub_file));
+       } elsif ($reboot_type eq "syslinux") {
+           dodie "SYSLINUX_LABEL not defined" if (!defined($syslinux_label));
        }
     }