Jenkins: Enable the lousy lapic timer since we don't have KVM
[akaros.git] / tools / jenkins / launcher.sh
index f8a443b..e906450 100755 (executable)
@@ -4,7 +4,7 @@
 # It analyzes what parts of the codebase have been modified, compiles everything
 # that is needed, and reports on the results. 
 
-set -e
+#set -e
 
 readonly TMP_DIR=tmp
 readonly DIFF_FILE=$TMP_DIR/changes.txt
@@ -32,7 +32,7 @@ readonly BUSYBOX_CONF_FILE=tools/patches/busybox/busybox-1.17.3-config
 ###############                 HELPER FUNCTIONS                 ###############
 ################################################################################
 function last_stable_build() {
-       curl -s localhost:8080/job/Test_akaros_github/lastStableBuild/api/json?tree=actions%5bbuildsByBranchName%5brevision%5bSHA1%5d%5d%5d | \
+       curl -s localhost:8080/job/$JOB_NAME/lastStableBuild/api/json?tree=actions%5bbuildsByBranchName%5brevision%5bSHA1%5d%5d%5d | \
                python -c 'import sys, json; print json.load(sys.stdin)["actions"][3]["buildsByBranchName"]["'$GIT_BRANCH'"]["revision"]["SHA1"]'
 }
 
@@ -93,6 +93,7 @@ function build_config() {
                   sed -i -e 's/CONFIG_64BIT=y/# CONFIG_64BIT is not set/' \
                          -e 's/# CONFIG_X86_32 is not set/CONFIG_X86_32=y/' \
                          -e 's/CONFIG_X86_64=y/# CONFIG_X86_64 is not set/' \
+                         -e 's/CONFIG_LOUSY_LAPIC_TIMER=y/# CONFIG_LOUSY_LAPIC_TIMER is not set/' \
                          .config
            ;;
        X86_64)  make ARCH=x86 defconfig
@@ -102,7 +103,7 @@ function build_config() {
        # Enable tests to run.
        # These don't take much to execute so we can run them always and just parse
        # results if needed.
-       echo "CONFIG_POSTBOOT_KERNEL_TESTING=y" >> .config
+       echo "CONFIG_KERNEL_TESTING=y" >> .config
        echo "CONFIG_USERSPACE_TESTING=y" >> .config
        # Set all config variables dependent on the above changes to their defaults
        # without prompting
@@ -135,8 +136,7 @@ X86_64_INSTDIR        := $WORKSPACE/install/${ARCH_SUBDIRS["X86_64"]}/
 
        # Create / clean directory where the cross compiler will be installed.
        CROSS_COMP_DIR=$WORKSPACE/install/${ARCH_SUBDIRS["$COMPILATION_ARCH"]}/
-       mkdir -p CROSS_COMP_DIR
-       rm -rf CROSS_COMP_DIR*
+       rm -rf $CROSS_COMP_DIR
 
        # Compile cross compiler.
        case "$COMPILATION_ARCH" in
@@ -174,13 +174,11 @@ function build_userspace() {
        make install-libs
 
        # Compile tests.
-       make tests
+       make utest
 
        # Fill memory with tests.
        make fill-kfs
 
-       # Recompile kernel.
-       make
        echo -e "[BUILD_USERSPACE]: End\n"
 }
 
@@ -202,17 +200,23 @@ function build_busybox() {
        fi
 
        # Build busybox and copy it into kfs
+       echo -e "Build busybox"
        cd $BUSYBOX_DIR
        make
        cp busybox_unstripped ../../kern/kfs/bin/busybox
        cd ../../
 
-       # Recompile kernel to include busybox
-       make
-
        echo -e "[BUILD_BUSYBOX]: End\n"
 }
 
+function build_all() {
+       build_config
+       build_cross_compiler
+       build_userspace
+       build_busybox
+       build_kernel
+}
+
 # TODO: This won't work for RISCV, it must be changed to whatever is used.
 function run_qemu() {
        echo -e "\n[RUN_AKAROS_IN_QEMU]: Begin"
@@ -222,9 +226,7 @@ function run_qemu() {
        make qemu > $AKAROS_OUTPUT_FILE &
        MAKE_PID=$!
 
-       # TODO: Rather than finishing after Kernel PB Tests, put a generic 
-       #       "C'est fini" statement somewhere and look for it
-       WAIT_RESULT=`$SCR_WAIT_UNTIL $AKAROS_OUTPUT_FILE END_KERNEL_POSTBOOT_TESTS \
+       WAIT_RESULT=`$SCR_WAIT_UNTIL $AKAROS_OUTPUT_FILE END_USERSPACE_TESTS \
            ${MAX_RUN_TIME:-100}`
 
        # Extract Qemu_launcher PID
@@ -234,8 +236,13 @@ function run_qemu() {
        # To kill qemu we need to send a USR1 signal to Qemu_launcher.
        kill -10 $QEMU_PID
 
+       # Then we wait....
        wait $MAKE_PID
 
+       # clean and cat the output of the file so we can see it in the console log
+       sed -i -e 's/\r//g' $AKAROS_OUTPUT_FILE
+       cat $AKAROS_OUTPUT_FILE
+
        echo -e "[RUN_AKAROS_IN_QEMU]: End\n"
 
        # If the run was terminated via a timeout, then we finish with an error.
@@ -249,56 +256,57 @@ function run_qemu() {
 
 if [ "$COMPILE_ALL" == true ]; then
        echo "Building all AKAROS"
-       build_config
-       
-       build_cross_compiler
-       build_kernel
-       build_userspace
-       build_busybox
-
+       build_all
        run_qemu
 
        AFFECTED_COMPONENTS="cross-compiler kernel userspace busybox"
 else
        # Save changed files between last tested commit and current one.
        git diff --stat $(last_stable_build) $GIT_COMMIT > $DIFF_FILE
-
-       # Extract build targets by parsing diff file.
-       AFFECTED_COMPONENTS=`$SCR_GIT_CHANGES $DIFF_FILE $CONF_COMP_COMPONENTS_FILE`
-       # Can contain {cross-compiler, kernel, userspace, busybox}
-
-       if [[ -n $AFFECTED_COMPONENTS ]]; 
-       then
-               echo "Detected changes in "$AFFECTED_COMPONENTS
-               build_config
-
-               if [[ $AFFECTED_COMPONENTS == *cross-compiler* ]]
+       if [ $? -ne 0 ]; then
+               echo "Diff failed, rebuild everything"
+               build_all
+               run_qemu
+
+               AFFECTED_COMPONENTS="cross-compiler kernel userspace busybox"
+       else 
+               # Extract build targets by parsing diff file.
+               AFFECTED_COMPONENTS=`$SCR_GIT_CHANGES $DIFF_FILE $CONF_COMP_COMPONENTS_FILE`
+               # Can contain {cross-compiler, kernel, userspace, busybox}
+
+               if [[ -n $AFFECTED_COMPONENTS ]]; 
                then
-                       build_cross_compiler
-                       build_kernel
-                       build_userspace
-                       build_busybox
-               else 
-                       if [[ $AFFECTED_COMPONENTS == *kernel* ]]
-                       then
-                               build_kernel
-                       fi
+                       echo "Detected changes in "$AFFECTED_COMPONENTS
+                       build_config
 
-                       if [[ $AFFECTED_COMPONENTS == *userspace* ]]
+                       if [[ $AFFECTED_COMPONENTS == *cross-compiler* ]]
                        then
+                               build_cross_compiler
                                build_userspace
-                       fi
-
-                       if [[ $AFFECTED_COMPONENTS == *busybox* ]]
-                       then
                                build_busybox
+                               build_kernel
+                       else 
+                               if [[ $AFFECTED_COMPONENTS == *userspace* ]]
+                               then
+                                       build_userspace
+                               fi
+
+                               if [[ $AFFECTED_COMPONENTS == *busybox* ]]
+                               then
+                                       build_busybox
+                               fi
+
+                               if [[ $AFFECTED_COMPONENTS == *kernel* ]]
+                               then
+                                       build_kernel
+                               fi
                        fi
+               else
+                       echo "Skipping build. No changes detected."
                fi
-       else
-               echo "Skipping build. No changes detected."
-       fi
 
-       run_qemu
+               run_qemu
+       fi
 fi
 
 
@@ -308,15 +316,8 @@ fi
 
 echo -e "\n[TEST_REPORTING]: Begin"
 
-TESTS_TO_RUN="KERNEL_POSTBOOT" # TODO(alfongj): Remove this when not needed.
-# for COMPONENT in "${AFFECTED_COMPONENTS_ARRAY[@]}"; 
-# do
-#      # TODO(alfongj): Add to tests to run the name of the test suites to be ran.
-#      # TESTS_TO_RUN="$TESTS_TO_RUN SOMETHING"
-# done
-
 # Generate test report
-$SCR_GEN_TEST_REPORTS $AKAROS_OUTPUT_FILE $TEST_OUTPUT_DIR $TESTS_TO_RUN
+$SCR_GEN_TEST_REPORTS $AKAROS_OUTPUT_FILE $TEST_OUTPUT_DIR 
 echo "Tests generated in $TEST_OUTPUT_DIR"
 
 echo -e "[TEST_REPORTING]: End\n"