diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..b01fe3f3 --- /dev/null +++ b/LICENSE @@ -0,0 +1,3 @@ +Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + +SPDX-License-Identifier: BSD-3-Clause-Clear diff --git a/Runner/init_env b/Runner/init_env index 82f5bd68..875489c8 100755 --- a/Runner/init_env +++ b/Runner/init_env @@ -1,11 +1,4 @@ # Source this file to setup the test suite environment -if [ -e '/var/Runner' ];then - export BASEDIR='/var/Runner' - export TOOLS='/var/Runner/utils' - export SUITES='/var/Runner/suites' - export CALIBRATION='/var/Runner/calib.txt' - export FTRACE_EVENTS='/var/Runner/ftrace_events' - export PATH=$PATH:'/bin' - export PATH=$PATH:'/sbin' -fi - +export BASEDIR=$(pwd) +export TOOLS=$(pwd)/utils +export SUITES=$(pwd)/suites \ No newline at end of file diff --git a/Runner/plans/AudioCI_PreMerge.yaml b/Runner/plans/AudioCI_PreMerge.yaml new file mode 100644 index 00000000..4c9f5632 --- /dev/null +++ b/Runner/plans/AudioCI_PreMerge.yaml @@ -0,0 +1,17 @@ +metadata: + format: Lava-Test Test Definition 1.0 + name: AUSanity + description: "Baseline AU Sanity test plan" + maintainer: + - vnarapar@qti.qualcomm.com + os: + - openembedded + scope: + - functional + devices: + - rb3gen2 + +run: + steps: + - cd Runner + - chmod -R 777 * \ No newline at end of file diff --git a/Runner/plans/KernelCI_PreMerge.yaml b/Runner/plans/KernelCI_PreMerge.yaml new file mode 100644 index 00000000..efa8a10a --- /dev/null +++ b/Runner/plans/KernelCI_PreMerge.yaml @@ -0,0 +1,55 @@ +metadata: + format: Lava-Test Test Definition 1.0 + name: AUSanity + description: "Baseline AU Sanity test plan" + maintainer: + - vnarapar@qti.qualcomm.com + os: + - openembedded + scope: + - functional + devices: + - rb3gen2 + +run: + steps: + - cd Runner + - chmod -R 777 * + - $PWD/suites/Kernel/FunctionalArea/baseport/adsp_remoteproc/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/adsp_remoteproc/adsp_remoteproc.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/cdsp_remoteproc/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/cdsp_remoteproc/cdsp_remoteproc.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/CPUFreq_Validation/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/CPUFreq_Validation/CPUFreq_Validation.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/GIC/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/GIC/GIC.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/hotplug/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/hotplug/hotplug.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/Interrupts/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/Interrupts/Interrupts.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/iommu/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/iommu/iommu.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/IPA/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/IPA/IPA.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/IPCC/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/IPCC/IPCC.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/irq/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/irq/irq.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/kaslr/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/kaslr/kaslr.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/MEMLAT/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/pinctrl/pinctrl.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/Reboot_health_check/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/Reboot_health_check/Reboot_health_check.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/remoteproc/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/remoteproc/remoteproc.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/RMNET/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/RMNET/RMNET.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/rngtest/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/smmu/smmu.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/storage/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/storage/storage.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/watchdog/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/watchdog/watchdog.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/wpss_remoteproc/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/wpss_remoteproc/wpss_remoteproc.res || true \ No newline at end of file diff --git a/Runner/plans/meta-qcom_PreMerge.yaml b/Runner/plans/meta-qcom_PreMerge.yaml new file mode 100644 index 00000000..88b6a261 --- /dev/null +++ b/Runner/plans/meta-qcom_PreMerge.yaml @@ -0,0 +1,59 @@ +metadata: + format: Lava-Test Test Definition 1.0 + name: AUSanity + description: "Baseline AU Sanity test plan" + maintainer: + - vnarapar@qti.qualcomm.com + os: + - openembedded + scope: + - functional + devices: + - rb3gen2 + +run: + steps: + - cd Runner + - chmod -R 777 * + - $PWD/suites/Kernel/FunctionalArea/baseport/adsp_remoteproc/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/adsp_remoteproc/adsp_remoteproc.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/cdsp_remoteproc/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/cdsp_remoteproc/cdsp_remoteproc.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/CPUFreq_Validation/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/CPUFreq_Validation/CPUFreq_Validation.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/GIC/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/GIC/GIC.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/hotplug/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/hotplug/hotplug.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/Interrupts/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/Interrupts/Interrupts.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/iommu/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/iommu/iommu.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/IPA/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/IPA/IPA.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/IPCC/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/IPCC/IPCC.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/irq/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/irq/irq.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/kaslr/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/kaslr/kaslr.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/pinctrl/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/pinctrl/pinctrl.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/qcrypto/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/qcrypto/qcrypto.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/Reboot_health_check/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/Reboot_health_check/Reboot_health_check.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/remoteproc/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/remoteproc/remoteproc.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/RMNET/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/RMNET/RMNET.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/smmu/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/smmu/smmu.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/storage/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/storage/storage.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/Timer/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/Timer/Timer.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/watchdog/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/watchdog/watchdog.res || true + - $PWD/suites/Kernel/FunctionalArea/baseport/wpss_remoteproc/run.sh || true + - $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/wpss_remoteproc/wpss_remoteproc.res || true \ No newline at end of file diff --git a/Runner/run-test.sh b/Runner/run-test.sh index 3dc14ae0..7e778b49 100755 --- a/Runner/run-test.sh +++ b/Runner/run-test.sh @@ -1,15 +1,42 @@ #!/bin/sh # Import test suite definitions -source /var/Runner/init_env + +source $(pwd)/init_env #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh # Find test case path by name find_test_case_by_name() { - local test_name="$1" - find /var/Runner/suites -type d -iname "$test_name" 2>/dev/null + # local test_name="$1" + # dir= "." + # Check if the file is a directory + if [ -d "$1" ]; then + # Get the directory name + dir_name_in_dir=${1##*/} + + # Check if the directory name matches the user input (ignoring case) + if [ "${dir_name_in_dir,,}" = "$test_name" ]; then + # Get the absolute path of the directory + abs_path=$(readlink -f "$1") + echo "$abs_path" + # Check if the run.sh file is present in the absolute path (ignoring case) + # if [ -f "$abs_path/run.sh" ]; then + # Print the absolute path of run.sh + # echo "Absolute path of run.sh: $abs_path/run.sh" + # fi + fi + fi + + # Recursively search for the directory in the subdirectory + for file in "$1"/*; do + # Check if the file is a directory + if [ -d "$file" ]; then + # Recursively search for the directory in the subdirectory + find_test_case_by_name "$file" + fi + done } # Execute a test case @@ -35,8 +62,9 @@ execute_test_case() { # Function to run a specific test case by name run_specific_test_by_name() { - local test_name="$1" - test_path=$(find_test_case_by_name "$test_name") + test_name="$1" + test_name=${test_name,,} + test_path=$(find_test_case_by_name ".") if [ -z "$test_path" ]; then log "Test case with name $test_name not found." else diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/BWMON/run.sh b/Runner/suites/Kernel/FunctionalArea/baseport/BWMON/run.sh old mode 100755 new mode 100644 index e1c7545a..1f61fb7d --- a/Runner/suites/Kernel/FunctionalArea/baseport/BWMON/run.sh +++ b/Runner/suites/Kernel/FunctionalArea/baseport/BWMON/run.sh @@ -1,10 +1,10 @@ #!/bin/sh # Import test suite definitions -/var/Runner/init_env +. $(pwd)/init_env TESTNAME="BWMON" #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "--------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" @@ -51,9 +51,9 @@ done if $incremented; then log_pass "$TESTNAME : Test Passed" - echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res + echo "$TESTNAME PASS" > $test_path/$TESTNAME.res else - log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + log_fail "$TESTNAME : Test Failed" + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res fi log_info "-------------------Completed $TESTNAME Testcase----------------------------" diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/Buses/run.sh b/Runner/suites/Kernel/FunctionalArea/baseport/Buses/run.sh old mode 100755 new mode 100644 index 43c931ec..ceb509ad --- a/Runner/suites/Kernel/FunctionalArea/baseport/Buses/run.sh +++ b/Runner/suites/Kernel/FunctionalArea/baseport/Buses/run.sh @@ -1,10 +1,10 @@ #!/bin/sh # Import test suite definitions -/var/Runner/init_env +. $(pwd)/init_env TESTNAME="Buses" #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "-----------------------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" @@ -18,9 +18,9 @@ output=$(i2c-msm-test -v -D /dev/i2c-0 -l | grep "ret:1") if echo "$output" | grep -q "Reading"; then log_pass "$TESTNAME : Test Passed" - echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res + echo "$TESTNAME PASS" > $test_path/$TESTNAME.res else - log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + log_fail "$TESTNAME : Test Failed" + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res fi log_info "-------------------Completed $TESTNAME Testcase----------------------------" \ No newline at end of file diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/CPUFreq_Validation/run.sh b/Runner/suites/Kernel/FunctionalArea/baseport/CPUFreq_Validation/run.sh old mode 100755 new mode 100644 index 222201d3..4958be45 --- a/Runner/suites/Kernel/FunctionalArea/baseport/CPUFreq_Validation/run.sh +++ b/Runner/suites/Kernel/FunctionalArea/baseport/CPUFreq_Validation/run.sh @@ -1,128 +1,123 @@ -#!/bin/bash +#!/bin/sh -# CPUFreq Validator: Parallel, Colorized -/var/Runner/init_env +. "$(pwd)/init_env" TESTNAME="CPUFreq_Validation" +. "$TOOLS/functestlib.sh" -#import test functions library -source $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "-----------------------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" log_info "=== CPUFreq Frequency Walker with Validation ===" -# Color codes -GREEN="\e[32m" -RED="\e[31m" -YELLOW="\e[33m" -BLUE="\e[34m" -NC="\e[0m" # No Color +# Color codes (ANSI escape sequences) +GREEN="\033[32m" +RED="\033[31m" +YELLOW="\033[33m" +BLUE="\033[34m" +NC="\033[0m" NUM_CPUS=$(nproc) -echo -e "${YELLOW}Detected $NUM_CPUS CPU cores.${NC}" +printf "${YELLOW}Detected %s CPU cores.${NC}\n" "$NUM_CPUS" -overall_pass=true -declare -A core_status +overall_pass=0 +status_dir="/tmp/cpufreq_status.$$" +mkdir -p "$status_dir" validate_cpu_core() { - local cpu=$1 - local core_id=$2 + cpu=$1 + core_id=$2 + status_file="$status_dir/core_$core_id" - echo -e "${BLUE}Processing $cpu...${NC}" + printf "${BLUE}Processing %s...${NC}\n" "$cpu" if [ ! -d "$cpu/cpufreq" ]; then - echo -e "${BLUE}[SKIP]${NC} $cpu does not support cpufreq." - core_status["$core_id"]="skip" + printf "${BLUE}[SKIP]${NC} %s does not support cpufreq.\n" "$cpu" + echo "skip" > "$status_file" return fi available_freqs=$(cat "$cpu/cpufreq/scaling_available_frequencies" 2>/dev/null) if [ -z "$available_freqs" ]; then - echo -e "${YELLOW}[INFO]${NC} No available frequencies for $cpu. Skipping..." - core_status["$core_id"]="skip" + printf "${YELLOW}[INFO]${NC} No available frequencies for %s. Skipping...\n" "$cpu" + echo "skip" > "$status_file" return fi - # Set governor to userspace if echo "userspace" | tee "$cpu/cpufreq/scaling_governor" > /dev/null; then - echo -e "${YELLOW}[INFO]${NC} Set governor to userspace." + printf "${YELLOW}[INFO]${NC} Set governor to userspace.\n" else - echo -e "${RED}[ERROR]${NC} Cannot set userspace governor for $cpu." - core_status["$core_id"]="fail" + printf "${RED}[ERROR]${NC} Cannot set userspace governor for %s.\n" "$cpu" + echo "fail" > "$status_file" return fi - core_status["$core_id"]="pass" # Assume pass unless a failure happens + echo "pass" > "$status_file" for freq in $available_freqs; do log_info "Setting $cpu to frequency $freq kHz..." - if echo $freq | tee "$cpu/cpufreq/scaling_setspeed" > /dev/null; then + if echo "$freq" | tee "$cpu/cpufreq/scaling_setspeed" > /dev/null; then sleep 0.2 actual_freq=$(cat "$cpu/cpufreq/scaling_cur_freq") - if [ "$actual_freq" == "$freq" ]; then - echo -e "${GREEN}[PASS]${NC} $cpu set to $freq kHz." + if [ "$actual_freq" = "$freq" ]; then + printf "${GREEN}[PASS]${NC} %s set to %s kHz.\n" "$cpu" "$freq" else - echo -e "${RED}[FAIL]${NC} Tried to set $cpu to $freq kHz, but current is $actual_freq kHz." - core_status["$core_id"]="fail" + printf "${RED}[FAIL]${NC} Tried to set %s to %s kHz, but current is %s kHz.\n" "$cpu" "$freq" "$actual_freq" + echo "fail" > "$status_file" fi else - echo -e "${RED}[ERROR]${NC} Failed to set $cpu to $freq kHz." - core_status["$core_id"]="fail" + printf "${RED}[ERROR]${NC} Failed to set %s to %s kHz.\n" "$cpu" "$freq" + echo "fail" > "$status_file" fi done - # Restore governor echo "Restoring $cpu governor to 'ondemand'..." echo "ondemand" | sudo tee "$cpu/cpufreq/scaling_governor" > /dev/null } -# Launch validation per CPU in parallel cpu_index=0 for cpu in /sys/devices/system/cpu/cpu[0-9]*; do validate_cpu_core "$cpu" "$cpu_index" & - ((cpu_index++)) + cpu_index=$((cpu_index + 1)) done -# Wait for all background jobs to finish wait -# Summary log_info "" log_info "=== Per-Core Test Summary ===" -for idx in "${!core_status[@]}"; do - status=${core_status[$idx]} +for status_file in "$status_dir"/core_*; do + idx=$(basename "$status_file" | cut -d_ -f2) + status=$(cat "$status_file") case "$status" in pass) - echo -e "CPU$idx: ${GREEN}[PASS]${NC}" + printf "CPU%s: ${GREEN}[PASS]${NC}\n" "$idx" ;; fail) - echo -e "CPU$idx: ${RED}[FAIL]${NC}" - overall_pass=false + printf "CPU%s: ${RED}[FAIL]${NC}\n" "$idx" + overall_pass=1 ;; skip) - echo -e "CPU$idx: ${BLUE}[SKIPPED]${NC}" + printf "CPU%s: ${BLUE}[SKIPPED]${NC}\n" "$idx" ;; *) - echo -e "CPU$idx: ${RED}[UNKNOWN STATUS]${NC}" - overall_pass=false + printf "CPU%s: ${RED}[UNKNOWN STATUS]${NC}\n" "$idx" + overall_pass=1 ;; esac done -# Overall result log_info "" log_info "=== Overall CPUFreq Validation Result ===" -if $overall_pass; then - echo -e "${GREEN}[OVERALL PASS]${NC} All CPUs validated successfully." - log_pass "$TESTNAME : Test Passed" - echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res +if [ "$overall_pass" -eq 0 ]; then + printf "${GREEN}[OVERALL PASS]${NC} All CPUs validated successfully.\n" + log_pass "$TESTNAME : Test Passed" + echo "$TESTNAME PASS" > "$test_path/$TESTNAME.res" + rm -r "$status_dir" exit 0 else - echo -e "${RED}[OVERALL FAIL]${NC} Some CPUs failed frequency validation." - log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + printf "${RED}[OVERALL FAIL]${NC} Some CPUs failed frequency validation.\n" + log_fail "$TESTNAME : Test Failed" + echo "$TESTNAME FAIL" > "$test_path/$TESTNAME.res" + rm -r "$status_dir" exit 1 -fi - -log_info "-------------------Completed $TESTNAME Testcase----------------------------" \ No newline at end of file +fi \ No newline at end of file diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/GIC/run.sh b/Runner/suites/Kernel/FunctionalArea/baseport/GIC/run.sh old mode 100755 new mode 100644 index d9b3dde9..d922c8ee --- a/Runner/suites/Kernel/FunctionalArea/baseport/GIC/run.sh +++ b/Runner/suites/Kernel/FunctionalArea/baseport/GIC/run.sh @@ -1,10 +1,10 @@ #!/bin/sh # Import test suite definitions -/var/Runner/init_env +. $(pwd)/init_env TESTNAME="GIC" #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "-----------------------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" @@ -43,7 +43,7 @@ echo "$initial_count" | while read -r line; do final_value=$(echo "$final_values_list" | sed -n "$((i+1))p") if [ "$initial_value" -lt "$final_value" ]; then echo "CPU $i: Timer count has incremented. Test PASSED" - log_pass "CPU $i: Timer count has incremented. Test PASSED" + log_pass "CPU $i: Timer count has incremented. Test PASSED" else echo "CPU $i: Timer count has not incremented. Test FAILED" log_fail "CPU $i: Timer count has not incremented. Test FAILED" @@ -51,13 +51,13 @@ echo "$initial_count" | while read -r line; do fi i=$((i+1)) done - echo $fail_test - if [ "$fail_test" = false ]; then - log_pass "$TESTNAME : Test Passed" - echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res - else - log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res - fi + echo $fail_test + if [ "$fail_test" = false ]; then + log_pass "$TESTNAME : Test Passed" + echo "$TESTNAME PASS" > $test_path/$TESTNAME.res + else + log_fail "$TESTNAME : Test Failed" + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res + fi done log_info "-------------------Completed $TESTNAME Testcase----------------------------" \ No newline at end of file diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/IPA/run.sh b/Runner/suites/Kernel/FunctionalArea/baseport/IPA/run.sh old mode 100755 new mode 100644 index 48dd295c..53f8b7b7 --- a/Runner/suites/Kernel/FunctionalArea/baseport/IPA/run.sh +++ b/Runner/suites/Kernel/FunctionalArea/baseport/IPA/run.sh @@ -1,25 +1,8 @@ #!/bin/sh # Import test suite definitions -source /var/Runner/init_env +. $(pwd)/init_env TESTNAME="IPA" -#import test functions library -log() { - local level="$1" - shift - # echo "$(date '+%Y-%m-%d %H:%M:%S') - $message" | tee -a /var/test_framework.log - echo "[$level] $(/bin/date '+%Y-%m-%d %H:%M:%S') - $*" | /usr/bin/tee -a /var/test_output.log -} -# Find test case path by name -find_test_case_by_name() { - local test_name="$1" - find /var/Runner/suites -type d -name "$test_name" 2>/dev/null -} -# Logging levels -log_info() { log "INFO" "$@"; } -log_pass() { log "PASS" "$@"; } -log_fail() { log "FAIL" "$@"; } -log_error() { log "ERROR" "$@"; } - +. "$TOOLS/functestlib.sh" test_path=$(find_test_case_by_name "$TESTNAME") log_info "-----------------------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" @@ -37,12 +20,12 @@ TEST=$(/sbin/insmod "$PATH") log_info "output of insmod $TEST" if /sbin/lsmod | /bin/grep "ipa"; then - log_info "$(/sbin/lsmod | /bin/grep "ipa")" + log_info "$(/sbin/lsmod | /bin/grep "ipa")" log_pass "$TESTNAME : Test Passed" - echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res + echo "$TESTNAME PASS" > $test_path/$TESTNAME.res else - log_error "rmnet module not running" - log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + log_error "rmnet module not running" + log_fail "$TESTNAME : Test Failed" + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res fi log_info "-------------------Completed $TESTNAME Testcase----------------------------" \ No newline at end of file diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/IPCC/run.sh b/Runner/suites/Kernel/FunctionalArea/baseport/IPCC/run.sh old mode 100755 new mode 100644 index 338a48d9..0f77c4eb --- a/Runner/suites/Kernel/FunctionalArea/baseport/IPCC/run.sh +++ b/Runner/suites/Kernel/FunctionalArea/baseport/IPCC/run.sh @@ -1,10 +1,10 @@ #!/bin/sh # Import test suite definitions -/var/Runner/init_env +. $(pwd)/init_env TESTNAME="IPCC" #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "--------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" @@ -15,9 +15,9 @@ count=$(echo "$output" | grep -c "running") if [ $count -eq 4 ]; then log_pass "$TESTNAME : Test Passed" - echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res + echo "$TESTNAME PASS" > $test_path/$TESTNAME.res else - log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + log_fail "$TESTNAME : Test Failed" + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res fi log_info "-------------------Completed $TESTNAME Testcase----------------------------" diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/Interrupts/run.sh b/Runner/suites/Kernel/FunctionalArea/baseport/Interrupts/run.sh old mode 100755 new mode 100644 index 0d45a281..e452ce2d --- a/Runner/suites/Kernel/FunctionalArea/baseport/Interrupts/run.sh +++ b/Runner/suites/Kernel/FunctionalArea/baseport/Interrupts/run.sh @@ -1,10 +1,10 @@ #!/bin/sh # Import test suite definitions -/var/Runner/init_env +. $(pwd)/init_env TESTNAME="Interrupts" #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "-----------------------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" @@ -43,7 +43,7 @@ echo "$initial_count" | while read -r line; do final_value=$(echo "$final_values_list" | sed -n "$((i+1))p") if [ "$initial_value" -lt "$final_value" ]; then echo "CPU $i: Timer count has incremented. Test PASSED" - log_pass "CPU $i: Timer count has incremented. Test PASSED" + log_pass "CPU $i: Timer count has incremented. Test PASSED" else echo "CPU $i: Timer count has not incremented. Test FAILED" log_fail "CPU $i: Timer count has not incremented. Test FAILED" @@ -51,13 +51,13 @@ echo "$initial_count" | while read -r line; do fi i=$((i+1)) done - echo $fail_test - if [ "$fail_test" = false ]; then - log_pass "$TESTNAME : Test Passed" - echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res - else - log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res - fi + echo $fail_test + if [ "$fail_test" = false ]; then + log_pass "$TESTNAME : Test Passed" + echo "$TESTNAME PASS" > $test_path/$TESTNAME.res + else + log_fail "$TESTNAME : Test Failed" + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res + fi done log_info "-------------------Completed $TESTNAME Testcase----------------------------" \ No newline at end of file diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/MEMLAT/run.sh b/Runner/suites/Kernel/FunctionalArea/baseport/MEMLAT/run.sh old mode 100755 new mode 100644 index f756b155..8d25b89a --- a/Runner/suites/Kernel/FunctionalArea/baseport/MEMLAT/run.sh +++ b/Runner/suites/Kernel/FunctionalArea/baseport/MEMLAT/run.sh @@ -1,9 +1,9 @@ #!/bin/sh # Import test suite definitions -/var/Runner/init_env +. $(pwd)/init_env TESTNAME="MEMLAT" #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") test_bin_path=$(find_test_case_bin_by_name "lat_mem_rd") log_info "-----------------------------------------------------------------------------------------" @@ -52,9 +52,9 @@ else fi if $incremented; then log_pass "$TESTNAME : Test Passed" - echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res + echo "$TESTNAME PASS" > $test_path/$TESTNAME.res else - log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + log_fail "$TESTNAME : Test Failed" + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res fi log_info "-------------------Completed $TESTNAME Testcase----------------------------" \ No newline at end of file diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/RMNET/run.sh b/Runner/suites/Kernel/FunctionalArea/baseport/RMNET/run.sh old mode 100755 new mode 100644 index acd8316f..a858f0c1 --- a/Runner/suites/Kernel/FunctionalArea/baseport/RMNET/run.sh +++ b/Runner/suites/Kernel/FunctionalArea/baseport/RMNET/run.sh @@ -1,26 +1,8 @@ #!/bin/sh # Import test suite definitions -source /var/Runner/init_env +. $(pwd)/init_env TESTNAME="RMNET" - -#import test functions library -log() { - local level="$1" - shift - # echo "$(date '+%Y-%m-%d %H:%M:%S') - $message" | tee -a /var/test_framework.log - echo "[$level] $(/bin/date '+%Y-%m-%d %H:%M:%S') - $*" | /usr/bin/tee -a /var/test_output.log -} -# Find test case path by name -find_test_case_by_name() { - local test_name="$1" - find /var/Runner/suites -type d -name "$test_name" 2>/dev/null -} -# Logging levels -log_info() { log "INFO" "$@"; } -log_pass() { log "PASS" "$@"; } -log_fail() { log "FAIL" "$@"; } -log_error() { log "ERROR" "$@"; } - +. "$TOOLS/functestlib.sh" test_path=$(find_test_case_by_name "$TESTNAME") log_info "-----------------------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" @@ -36,12 +18,12 @@ TEST=$(/sbin/insmod "$PATH") log_info "output of insmod $TEST" if /sbin/lsmod | /bin/grep "rmnet"; then - log_info "$(/sbin/lsmod | /bin/grep "rmnet")" + log_info "$(/sbin/lsmod | /bin/grep "rmnet")" log_pass "$TESTNAME : Test Passed" - echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res + echo "$TESTNAME PASS" > $test_path/$TESTNAME.res else - log_error "rmnet module not running" - log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + log_error "rmnet module not running" + log_fail "$TESTNAME : Test Failed" + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res fi log_info "-------------------Completed $TESTNAME Testcase----------------------------" \ No newline at end of file diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/Reboot_health_check/Readme.md b/Runner/suites/Kernel/FunctionalArea/baseport/Reboot_health_check/Readme.md old mode 100755 new mode 100644 diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/Reboot_health_check/run.sh b/Runner/suites/Kernel/FunctionalArea/baseport/Reboot_health_check/run.sh old mode 100755 new mode 100644 index 9a185da4..5611eb19 --- a/Runner/suites/Kernel/FunctionalArea/baseport/Reboot_health_check/run.sh +++ b/Runner/suites/Kernel/FunctionalArea/baseport/Reboot_health_check/run.sh @@ -1,9 +1,9 @@ #!/bin/sh # Import test suite definitions -/var/Runner/init_env +. $(pwd)/init_env TESTNAME="Reboot_health_check" #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") # Directory for health check files diff --git a/common/src/Reboot/setup_systemd.sh b/Runner/suites/Kernel/FunctionalArea/baseport/Reboot_health_check/setup_systemd.sh old mode 100755 new mode 100644 similarity index 100% rename from common/src/Reboot/setup_systemd.sh rename to Runner/suites/Kernel/FunctionalArea/baseport/Reboot_health_check/setup_systemd.sh diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/Timer/run.sh b/Runner/suites/Kernel/FunctionalArea/baseport/Timer/run.sh old mode 100755 new mode 100644 index 45c2f8d4..75ab564c --- a/Runner/suites/Kernel/FunctionalArea/baseport/Timer/run.sh +++ b/Runner/suites/Kernel/FunctionalArea/baseport/Timer/run.sh @@ -1,10 +1,10 @@ #!/bin/sh # Import test suite definitions -/var/Runner/init_env +. $(pwd)/init_env TESTNAME="Timer" #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "-----------------------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" @@ -20,9 +20,9 @@ OUTPUT=$($BINARY_PATH) # Check if "pass:7" is in the output if [[ $OUTPUT == *"pass:7"* ]]; then log_pass "$TESTNAME : Test Passed" - echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res + echo "$TESTNAME PASS" > $test_path/$TESTNAME.res else - log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + log_fail "$TESTNAME : Test Failed" + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res fi log_info "-------------------Completed $TESTNAME Testcase----------------------------" \ No newline at end of file diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/adsp_remoteproc/run.sh b/Runner/suites/Kernel/FunctionalArea/baseport/adsp_remoteproc/run.sh old mode 100755 new mode 100644 index 490256ac..7b08f25e --- a/Runner/suites/Kernel/FunctionalArea/baseport/adsp_remoteproc/run.sh +++ b/Runner/suites/Kernel/FunctionalArea/baseport/adsp_remoteproc/run.sh @@ -1,10 +1,10 @@ #!/bin/sh # Import test suite definitions -/var/Runner/init_env +. $(pwd)/init_env TESTNAME="adsp_remoteproc" #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "--------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" @@ -25,8 +25,8 @@ state1=$(cat ${remoteproc_path}/state) if [ "$state1" != "running" ]; then log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res - exit 1 + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res + exit 1 fi # Execute command 2 (no output expected) @@ -36,11 +36,11 @@ echo stop > ${remoteproc_path}/state # Execute command 3 and check if the output is "offline" state3=$(cat ${remoteproc_path}/state) if [ "$state3" != "offline" ]; then - log_fail "adsp stop failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + log_fail "adsp stop failed" + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res exit 1 else - log_pass "adsp stop successful" + log_pass "adsp stop successful" fi log_info "Restarting remoteproc" # Execute command 4 (no output expected) @@ -49,13 +49,13 @@ echo start > ${remoteproc_path}/state # Execute command 5 and check if the output is "running" state5=$(cat ${remoteproc_path}/state) if [ "$state5" != "running" ]; then - log_fail "adsp start failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + log_fail "adsp start failed" + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res exit 1 fi # If all checks pass, print "PASS" echo "adsp PASS" log_pass "adsp PASS" -echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res +echo "$TESTNAME PASS" > $test_path/$TESTNAME.res log_info "-------------------Completed $TESTNAME Testcase----------------------------" diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/cdsp_remoteproc/run.sh b/Runner/suites/Kernel/FunctionalArea/baseport/cdsp_remoteproc/run.sh old mode 100755 new mode 100644 index acb22368..dadfd26f --- a/Runner/suites/Kernel/FunctionalArea/baseport/cdsp_remoteproc/run.sh +++ b/Runner/suites/Kernel/FunctionalArea/baseport/cdsp_remoteproc/run.sh @@ -1,10 +1,10 @@ #!/bin/sh # Import test suite definitions -/var/Runner/init_env +. $(pwd)/init_env TESTNAME="cdsp_remoteproc" #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "-----------------------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" @@ -24,8 +24,8 @@ remoteproc_path="/sys/class/remoteproc/remoteproc${remoteproc_number}" state1=$(cat ${remoteproc_path}/state) if [ "$state1" != "running" ]; then log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res - exit 1 + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res + exit 1 fi # Execute command 2 (no output expected) @@ -34,11 +34,11 @@ echo stop > ${remoteproc_path}/state # Execute command 3 and check if the output is "offline" state3=$(cat ${remoteproc_path}/state) if [ "$state3" != "offline" ]; then - log_fail "cdsp stop failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + log_fail "cdsp stop failed" + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res exit 1 else - log_pass "cdsp stop successful" + log_pass "cdsp stop successful" fi log_info "Restarting remoteproc" # Execute command 4 (no output expected) @@ -48,12 +48,12 @@ echo start > ${remoteproc_path}/state state5=$(cat ${remoteproc_path}/state) if [ "$state5" != "running" ]; then log_fail "cdsp start failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res exit 1 fi # If all checks pass, print "PASS" echo "cdsp PASS" log_pass "cdsp PASS" -echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res +echo "$TESTNAME PASS" > $test_path/$TESTNAME.res log_info "-------------------Completed $TESTNAME Testcase----------------------------" diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/hotplug/run.sh b/Runner/suites/Kernel/FunctionalArea/baseport/hotplug/run.sh old mode 100755 new mode 100644 index db14105c..e3ddc09f --- a/Runner/suites/Kernel/FunctionalArea/baseport/hotplug/run.sh +++ b/Runner/suites/Kernel/FunctionalArea/baseport/hotplug/run.sh @@ -1,10 +1,10 @@ #!/bin/sh # Import test suite definitions -/var/Runner/init_env +. $(pwd)/init_env TESTNAME="hotplug" #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "--------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" @@ -15,16 +15,16 @@ check_cpu_status() { op=0 offline_cpu() { echo 0 > "/sys/devices/system/cpu/$1/online" - op=$(cat "/sys/devices/system/cpu/$1/online") - if [ "$op" -ne 1 ]; then + op=$(cat "/sys/devices/system/cpu/$1/online") + if [ "$op" -ne 1 ]; then log_pass "/sys/devices/system/cpu/$1/online is offline as expected" fi } online_cpu() { echo 1 > "/sys/devices/system/cpu/$1/online" - op=$(cat "/sys/devices/system/cpu/$1/online") - if [ "$op" -ne 0 ]; then + op=$(cat "/sys/devices/system/cpu/$1/online") + if [ "$op" -ne 0 ]; then log_pass "/sys/devices/system/cpu/$1/online is online as expected" fi } @@ -63,9 +63,9 @@ check_cpu_status | tee -a "$LOG_FILE" # Print overall test result if [ "$test_passed" = true ]; then log_pass "$TESTNAME : Test Passed" - echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res + echo "$TESTNAME PASS" > $test_path/$TESTNAME.res else - log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + log_fail "$TESTNAME : Test Failed" + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res fi log_info "-------------------Completed $TESTNAME Testcase----------------------------" diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/iommu/run.sh b/Runner/suites/Kernel/FunctionalArea/baseport/iommu/run.sh old mode 100755 new mode 100644 index fea912f3..4dccc7ce --- a/Runner/suites/Kernel/FunctionalArea/baseport/iommu/run.sh +++ b/Runner/suites/Kernel/FunctionalArea/baseport/iommu/run.sh @@ -1,10 +1,10 @@ #!/bin/sh # Import test suite definitions -/var/Runner/init_env +. $(pwd)/init_env TESTNAME="iommu" #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "--------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" @@ -15,9 +15,9 @@ OUTPUT=$(dmesg | grep iommu) # Check if the output is null if [ -z "$OUTPUT" ]; then log_pass "$TESTNAME : Test Passed" - echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res + echo "$TESTNAME PASS" > $test_path/$TESTNAME.res else - log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + log_fail "$TESTNAME : Test Failed" + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res fi log_info "-------------------Completed $TESTNAME Testcase----------------------------" diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/irq/run.sh b/Runner/suites/Kernel/FunctionalArea/baseport/irq/run.sh old mode 100755 new mode 100644 index 8c492287..1c8028af --- a/Runner/suites/Kernel/FunctionalArea/baseport/irq/run.sh +++ b/Runner/suites/Kernel/FunctionalArea/baseport/irq/run.sh @@ -1,10 +1,10 @@ #!/bin/sh # Import test suite definitions -/var/Runner/init_env +. $(pwd)/init_env TESTNAME="irq" #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "-----------------------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" @@ -51,10 +51,10 @@ echo "$initial_count" | while read -r line; do if [ "$fail_test" = false ]; then log_pass "$TESTNAME : Test Passed" - echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res + echo "$TESTNAME PASS" > $test_path/$TESTNAME.res else log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res fi done log_info "-------------------Completed $TESTNAME Testcase----------------------------" diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/kaslr/run.sh b/Runner/suites/Kernel/FunctionalArea/baseport/kaslr/run.sh old mode 100755 new mode 100644 index 6a32128f..7265a81b --- a/Runner/suites/Kernel/FunctionalArea/baseport/kaslr/run.sh +++ b/Runner/suites/Kernel/FunctionalArea/baseport/kaslr/run.sh @@ -1,9 +1,9 @@ #!/bin/sh # Import test suite definitions -/var/Runner/init_env +. $(pwd)/init_env TESTNAME="kaslr" #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "--------------------------------------------------------------------------" @@ -18,9 +18,9 @@ value=$(echo $output | awk '{print $1}') if [ $value == "0000000000000000" ]; then log_pass "$TESTNAME : Test Passed" - echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res + echo "$TESTNAME PASS" > $test_path/$TESTNAME.res else - log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + log_fail "$TESTNAME : Test Failed" + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res fi log_info "-------------------Completed $TESTNAME Testcase----------------------------" diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/pinctrl/run.sh b/Runner/suites/Kernel/FunctionalArea/baseport/pinctrl/run.sh old mode 100755 new mode 100644 index 8c717ffc..f1fb3535 --- a/Runner/suites/Kernel/FunctionalArea/baseport/pinctrl/run.sh +++ b/Runner/suites/Kernel/FunctionalArea/baseport/pinctrl/run.sh @@ -1,10 +1,10 @@ #!/bin/sh # Import test suite definitions -/var/Runner/init_env +. $(pwd)/init_env TESTNAME="pinctrl" #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "-----------------------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" @@ -16,9 +16,9 @@ output=$(ls /sys/kernel/debug/pinctrl) # Print overall test result if [ -z "$output" ]; then log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res else - log_pass "$TESTNAME : Test Passed" - echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res + log_pass "$TESTNAME : Test Passed" + echo "$TESTNAME PASS" > $test_path/$TESTNAME.res fi log_info "-------------------Completed $TESTNAME Testcase----------------------------" \ No newline at end of file diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/qcrypto/run.sh b/Runner/suites/Kernel/FunctionalArea/baseport/qcrypto/run.sh old mode 100755 new mode 100644 index 8dbdf987..2bfa13ac --- a/Runner/suites/Kernel/FunctionalArea/baseport/qcrypto/run.sh +++ b/Runner/suites/Kernel/FunctionalArea/baseport/qcrypto/run.sh @@ -1,10 +1,10 @@ #!/bin/sh # Import test suite definitions -/var/Runner/init_env +. $(pwd)/init_env TESTNAME="qcrypto" #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "-----------------------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" @@ -19,9 +19,9 @@ echo $? if [ $? -eq 0 ]; then log_pass "$TESTNAME : Test Passed" - echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res + echo "$TESTNAME PASS" > $test_path/$TESTNAME.res else - log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + log_fail "$TESTNAME : Test Failed" + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res fi log_info "-------------------Completed $TESTNAME Testcase----------------------------" \ No newline at end of file diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/remoteproc/run.sh b/Runner/suites/Kernel/FunctionalArea/baseport/remoteproc/run.sh old mode 100755 new mode 100644 index 1699501b..e05bcd4a --- a/Runner/suites/Kernel/FunctionalArea/baseport/remoteproc/run.sh +++ b/Runner/suites/Kernel/FunctionalArea/baseport/remoteproc/run.sh @@ -1,10 +1,10 @@ #!/bin/sh # Import test suite definitions -/var/Runner/init_env +. $(pwd)/init_env TESTNAME="remoteproc" #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "-----------------------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" @@ -23,9 +23,9 @@ log_info "rproc subsystems in running state : $count, expected subsystems : $sub # Print overall test result if [ $count -eq $subsystem_count ]; then log_pass "$TESTNAME : Test Passed" - echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res + echo "$TESTNAME PASS" > $test_path/$TESTNAME.res else - log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + log_fail "$TESTNAME : Test Failed" + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res fi log_info "-------------------Completed $TESTNAME Testcase----------------------------" \ No newline at end of file diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/rngtest/run.sh b/Runner/suites/Kernel/FunctionalArea/baseport/rngtest/run.sh old mode 100755 new mode 100644 index a1b1e73e..843857d9 --- a/Runner/suites/Kernel/FunctionalArea/baseport/rngtest/run.sh +++ b/Runner/suites/Kernel/FunctionalArea/baseport/rngtest/run.sh @@ -1,10 +1,10 @@ #!/bin/sh # Import test suite definitions -/var/Runner/init_env +. $(pwd)/init_env TESTNAME="rngtest" #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "-----------------------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" @@ -21,9 +21,9 @@ value=$(cat /tmp/rngtest_value.txt) if [ "$value" -lt 10 ]; then log_pass "$TESTNAME : Test Passed" - echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res + echo "$TESTNAME PASS" > $test_path/$TESTNAME.res else - log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + log_fail "$TESTNAME : Test Failed" + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res fi log_info "-------------------Completed $TESTNAME Testcase----------------------------" \ No newline at end of file diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/smmu/run.sh b/Runner/suites/Kernel/FunctionalArea/baseport/smmu/run.sh old mode 100755 new mode 100644 index ee8ce1b5..2e43a6d0 --- a/Runner/suites/Kernel/FunctionalArea/baseport/smmu/run.sh +++ b/Runner/suites/Kernel/FunctionalArea/baseport/smmu/run.sh @@ -1,10 +1,10 @@ #!/bin/sh # Import test suite definitions -/var/Runner/init_env +. $(pwd)/init_env TESTNAME="smmu" #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "-----------------------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" @@ -15,9 +15,9 @@ OUTPUT=$(dmesg | grep iommu) # Check if the output is null if [ -z "$OUTPUT" ]; then log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res else - log_pass "$TESTNAME : Test Passed" - echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res + log_pass "$TESTNAME : Test Passed" + echo "$TESTNAME PASS" > $test_path/$TESTNAME.res fi log_info "-------------------Completed $TESTNAME Testcase----------------------------" \ No newline at end of file diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/storage/run.sh b/Runner/suites/Kernel/FunctionalArea/baseport/storage/run.sh old mode 100755 new mode 100644 index fc479af2..bd6344a4 --- a/Runner/suites/Kernel/FunctionalArea/baseport/storage/run.sh +++ b/Runner/suites/Kernel/FunctionalArea/baseport/storage/run.sh @@ -1,10 +1,10 @@ #!/bin/sh # Import test suite definitions -/var/Runner/init_env +. $(pwd)/init_env TESTNAME="storage" #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "-----------------------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" @@ -20,22 +20,22 @@ if [ -f /tmp/a.txt ]; then if [ -s /tmp/a.txt ]; then log_pass "File /tmp/a.txt is not empty. Test Passed" log_pass "$TESTNAME : Test Passed" - echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res + echo "$TESTNAME PASS" > $test_path/$TESTNAME.res else log_fail "File /tmp/a.txt is empty. Test Failed." log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res fi else log_fail "File /tmp/a.txt is not created. Test Failed" log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res fi if [ -f /tmp/a.txt ]; then log_pass "$TESTNAME : Test Passed" - echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res + echo "$TESTNAME PASS" > $test_path/$TESTNAME.res else - log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + log_fail "$TESTNAME : Test Failed" + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res fi log_info "-------------------Completed $TESTNAME Testcase----------------------------" \ No newline at end of file diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/watchdog/run.sh b/Runner/suites/Kernel/FunctionalArea/baseport/watchdog/run.sh old mode 100755 new mode 100644 index 568ff5f3..62d9f089 --- a/Runner/suites/Kernel/FunctionalArea/baseport/watchdog/run.sh +++ b/Runner/suites/Kernel/FunctionalArea/baseport/watchdog/run.sh @@ -1,10 +1,10 @@ #!/bin/sh # Import test suite definitions -/var/Runner/init_env +. $(pwd)/init_env TESTNAME="watchdog" #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "--------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" @@ -12,10 +12,10 @@ log_info "-------------------Starting $TESTNAME Testcase------------------------ if [ -e /dev/watchdog ]; then log_pass "/dev/watchdog node is present." log_pass "$TESTNAME : Test Passed" - echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res + echo "$TESTNAME PASS" > $test_path/$TESTNAME.res else - log_fail "/dev/watchdog node is not present." - log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + log_fail "/dev/watchdog node is not present." + log_fail "$TESTNAME : Test Failed" + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res fi log_info "-------------------Completed $TESTNAME Testcase---------------------------" diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/wpss_remoteproc/run.sh b/Runner/suites/Kernel/FunctionalArea/baseport/wpss_remoteproc/run.sh old mode 100755 new mode 100644 index 0af4dfa6..5b142390 --- a/Runner/suites/Kernel/FunctionalArea/baseport/wpss_remoteproc/run.sh +++ b/Runner/suites/Kernel/FunctionalArea/baseport/wpss_remoteproc/run.sh @@ -1,10 +1,10 @@ #!/bin/sh # Import test suite definitions -/var/Runner/init_env +. $(pwd)/init_env TESTNAME="wpss_remoteproc" #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "-----------------------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" @@ -23,8 +23,8 @@ remoteproc_path="/sys/class/remoteproc/remoteproc${remoteproc_number}" state1=$(cat ${remoteproc_path}/state) if [ "$state1" != "running" ]; then log_fail "$TESTNAME : Test Failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res - exit 1 + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res + exit 1 fi # Execute command 2 (no output expected) @@ -34,10 +34,10 @@ echo stop > ${remoteproc_path}/state state3=$(cat ${remoteproc_path}/state) if [ "$state3" != "offline" ]; then log_fail "wpss stop failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res exit 1 else - log_pass "wpss stop successful" + log_pass "wpss stop successful" fi # Execute command 4 (no output expected) @@ -47,12 +47,12 @@ echo start > ${remoteproc_path}/state state5=$(cat ${remoteproc_path}/state) if [ "$state5" != "running" ]; then log_fail "wpss start failed" - echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res + echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res exit 1 fi # If all checks pass, print "PASS" echo "wpss PASS" log_pass "wpss PASS" -echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res +echo "$TESTNAME PASS" > $test_path/$TESTNAME.res log_info "-------------------Completed $TESTNAME Testcase----------------------------" diff --git a/Runner/suites/Multimedia/DSP_AudioPD/run.sh b/Runner/suites/Multimedia/DSP_AudioPD/run.sh index e6ad2ffc..a94ea886 100755 --- a/Runner/suites/Multimedia/DSP_AudioPD/run.sh +++ b/Runner/suites/Multimedia/DSP_AudioPD/run.sh @@ -4,7 +4,7 @@ TESTNAME="DSP_AudioPD" #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "--------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" diff --git a/Runner/suites/Multimedia/Graphics/run.sh b/Runner/suites/Multimedia/Graphics/run.sh index 031d882d..f7f96f63 100755 --- a/Runner/suites/Multimedia/Graphics/run.sh +++ b/Runner/suites/Multimedia/Graphics/run.sh @@ -4,7 +4,7 @@ TESTNAME="Graphics" #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "-----------------------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" diff --git a/Runner/suites/Multimedia/Video/iris_v4l2_video_decode/run.sh b/Runner/suites/Multimedia/Video/iris_v4l2_video_decode/run.sh index 0990bb13..68be7d65 100755 --- a/Runner/suites/Multimedia/Video/iris_v4l2_video_decode/run.sh +++ b/Runner/suites/Multimedia/Video/iris_v4l2_video_decode/run.sh @@ -4,7 +4,7 @@ TESTNAME="video_decode" #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "-----------------------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" diff --git a/Runner/suites/Multimedia/Video/iris_v4l2_video_encode/run.sh b/Runner/suites/Multimedia/Video/iris_v4l2_video_encode/run.sh index 239129dc..ee63ef4f 100755 --- a/Runner/suites/Multimedia/Video/iris_v4l2_video_encode/run.sh +++ b/Runner/suites/Multimedia/Video/iris_v4l2_video_encode/run.sh @@ -4,7 +4,7 @@ TESTNAME="video_encode" #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh test_path=$(find_test_case_by_name "$TESTNAME") log_info "-----------------------------------------------------------------------------------------" log_info "-------------------Starting $TESTNAME Testcase----------------------------" diff --git a/Runner/utils/basics.sh b/Runner/utils/basics.sh index d0a35d66..ff1b4677 100755 --- a/Runner/utils/basics.sh +++ b/Runner/utils/basics.sh @@ -1,11 +1,11 @@ # Import test suite definitions -source ../../../../init_env +. $(pwd)/init_env #import platform . $TOOLS/platform.sh #import test functions library -source $TOOLS/functestlib.sh +. $TOOLS/functestlib.sh # CPU_FAST CPU_SLOW FTRACE_START_MARKER are used by the ftrace libraries @@ -37,23 +37,23 @@ PART_FAST=`echo $CONFIG_TARGET_BIG_CPUPART` commaslow= commafast= for cpu in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 21 22 23 24 25 26 ; do - $TASKSET -part $cpu,$IMPLEMENTER,$PART_SLOW >/dev/null - if [ $? == 0 ] ; then - CPU_SLOW=$CPU_SLOW$commaslow$cpu - commaslow=, - fi - $TASKSET -part $cpu,$IMPLEMENTER,$PART_FAST >/dev/null - if [ $? == 0 ] ; then - CPU_FAST=$CPU_FAST$commafast$cpu - commafast=, - fi + $TASKSET -part $cpu,$IMPLEMENTER,$PART_SLOW >/dev/null + if [ $? == 0 ] ; then + CPU_SLOW=$CPU_SLOW$commaslow$cpu + commaslow=, + fi + $TASKSET -part $cpu,$IMPLEMENTER,$PART_FAST >/dev/null + if [ $? == 0 ] ; then + CPU_FAST=$CPU_FAST$commafast$cpu + commafast=, + fi done echo "Fast CPU $CPU_FAST Slow CPU $CPU_SLOW" if [ ! -e /proc/sys/kernel/sched_upmigrate ] || [ ! -e /proc/sys/kernel/sched_downmigrate ]; then - echo "up-upmigrate and down-downmigrate values not exported. Precondition failure" - #non-zero exit signals test runner to declare this test as a failure - exit 1 + echo "up-upmigrate and down-downmigrate values not exported. Precondition failure" + #non-zero exit signals test runner to declare this test as a failure + exit 1 fi UP_THRESHOLD_1024=$(cat '/proc/sys/kernel/sched_upmigrate' | cut -f 1) @@ -84,89 +84,89 @@ HOG_PID= copy_trace_events() { - if [ -f $FTRACE_EVENTS/header_page ] ; then - echo "Trace events already copied" - TRACE_EVENTS_PATH=$FTRACE_EVENTS - return - fi - - echo "Copying trace events..." - odir=`pwd` - cd /sys/kernel/debug/tracing/events - mkdir $FTRACE_EVENTS - for i in * ; do - if [ -f $i ] ; then - cat $i > $FTRACE_EVENTS/$i - else - old=`pwd` - cd $i - mkdir $FTRACE_EVENTS/$i/ - for j in * ; do - if [ -f $j/format ] ; then - mkdir $FTRACE_EVENTS/$i/$j - cat $j/format > $FTRACE_EVENTS/$i/$j/format - fi - done - cd $old - fi - done - cd $odir - TRACE_EVENTS_PATH=$FTRACE_EVENTS + if [ -f $FTRACE_EVENTS/header_page ] ; then + echo "Trace events already copied" + TRACE_EVENTS_PATH=$FTRACE_EVENTS + return + fi + + echo "Copying trace events..." + odir=`pwd` + cd /sys/kernel/debug/tracing/events + mkdir $FTRACE_EVENTS + for i in * ; do + if [ -f $i ] ; then + cat $i > $FTRACE_EVENTS/$i + else + old=`pwd` + cd $i + mkdir $FTRACE_EVENTS/$i/ + for j in * ; do + if [ -f $j/format ] ; then + mkdir $FTRACE_EVENTS/$i/$j + cat $j/format > $FTRACE_EVENTS/$i/$j/format + fi + done + cd $old + fi + done + cd $odir + TRACE_EVENTS_PATH=$FTRACE_EVENTS } get_uptime() { - _temp="`cat /proc/uptime`" + _temp="`cat /proc/uptime`" # RESULT is the second integer of /proc/uptime - for _temp1 in $_temp ; do - RESULT=$_temp1 - done + for _temp1 in $_temp ; do + RESULT=$_temp1 + done } hog_cpu_fast() { - $HOG_CPU $CPU_FAST,$CPU_FAST,$CPU_FAST & - HOG_PID="$HOG_PID $!" + $HOG_CPU $CPU_FAST,$CPU_FAST,$CPU_FAST & + HOG_PID="$HOG_PID $!" } hog_cpu_slow() { - $HOG_CPU $CPU_SLOW,$CPU_SLOW,$CPU_SLOW & - HOG_PID="$HOG_PID $!" + $HOG_CPU $CPU_SLOW,$CPU_SLOW,$CPU_SLOW & + HOG_PID="$HOG_PID $!" } unhog_cpu() { - for i in $HOG_PID ; do - kill -10 $i - wait $i - done - HOG_PID= + for i in $HOG_PID ; do + kill -10 $i + wait $i + done + HOG_PID= } taskset_cpuslow() { - $TASKSET -pc $CPU_SLOW $1 + $TASKSET -pc $CPU_SLOW $1 } taskset_cpufast() { - $TASKSET -pc $CPU_FAST $1 + $TASKSET -pc $CPU_FAST $1 } taskset_cpuany() { - $TASKSET -pc $CPU_FAST,$CPU_SLOW $1 + $TASKSET -pc $CPU_FAST,$CPU_SLOW $1 } CALIBRATION=${CALIBRATION:-$BASEDIR/calib.txt} calibrate_tasklib() { - # share between test suites if possible - if [ ! -f $CALIBRATION ] ; then - $LOAD_GENERATOR --calibrate - mv calib.txt $CALIBRATION - fi + # share between test suites if possible + if [ ! -f $CALIBRATION ] ; then + $LOAD_GENERATOR --calibrate + mv calib.txt $CALIBRATION + fi } # Force load_generator calibration each time this file is sourced. @@ -176,231 +176,231 @@ calibrate_tasklib load_generator() { - echo "Using tasklibrary calibdation file: $CALIBRATION" - $LOAD_GENERATOR --calibfile=$CALIBRATION --loadseq=$1 & - RESULT=$! - if [ "$2" == "START_SLOW" ] ; then - taskset_cpuslow $RESULT - for ii in 0 ; do sleep 1; taskset_cpuany $RESULT ; done & - fi - if [ "$2" == "START_FAST" ] ; then - taskset_cpufast $RESULT - for ii in 0 ; do sleep 1; taskset_cpuany $RESULT ; done & - fi - if [ "$2" == "STARTSTOP_SLOW" ] ; then - taskset_cpuslow $RESULT - fi - if [ "$2" == "STARTSTOP_FAST" ] ; then - taskset_cpufast $RESULT - fi - echo "#load_generator PID=$RESULT COMMAND=$1" + echo "Using tasklibrary calibdation file: $CALIBRATION" + $LOAD_GENERATOR --calibfile=$CALIBRATION --loadseq=$1 & + RESULT=$! + if [ "$2" == "START_SLOW" ] ; then + taskset_cpuslow $RESULT + for ii in 0 ; do sleep 1; taskset_cpuany $RESULT ; done & + fi + if [ "$2" == "START_FAST" ] ; then + taskset_cpufast $RESULT + for ii in 0 ; do sleep 1; taskset_cpuany $RESULT ; done & + fi + if [ "$2" == "STARTSTOP_SLOW" ] ; then + taskset_cpuslow $RESULT + fi + if [ "$2" == "STARTSTOP_FAST" ] ; then + taskset_cpufast $RESULT + fi + echo "#load_generator PID=$RESULT COMMAND=$1" } ftrace_start() { - BOOST_GOVERNOR=${1:-1} - - if [ $ANDROID -eq 1 ]; then - echo "Stop all android services" - stop - fi - - if [ $BOOST_GOVERNOR -eq 1 ]; then - echo "Save current CPUFreq governors configuration" - i=0 - FTRACE_OLD_GOV="" - while [ $i != 9999 ] ; do - temp="` cat /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor 2>/dev/null`" - if [ "$temp" == "" ] ; then - i=9999 - else - let i=$i+1 - FTRACE_OLD_GOV="$FTRACE_OLD_GOV $temp" - fi - done - - echo "Set CPUFreq governor to [performance]" - i=0 - while [ $i != 9999 ] ; do - temp="` cat /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor 2>/dev/null`" - if [ "$temp" == "" ] ; then - i=9999 - else - echo performance > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor - let i=$i+1 - fi - done - fi - - mount -t debugfs none /sys/kernel/debug/ 2>/dev/null - get_uptime - FTRACE_START_MARKER=$RESULT - - echo "Start FTrace..." - $TRACE_CMD_EXE reset - $TRACE_CMD_EXE start -b $CONFIG_FTRACE_BUFFER_SIZE $CONFIG_FTRACE_EVENTS - echo $FTRACE_START_MARKER > /sys/kernel/debug/tracing/trace_marker - echo "Tracing started @ $FTRACE_START_MARKER" + BOOST_GOVERNOR=${1:-1} + + if [ $ANDROID -eq 1 ]; then + echo "Stop all android services" + stop + fi + + if [ $BOOST_GOVERNOR -eq 1 ]; then + echo "Save current CPUFreq governors configuration" + i=0 + FTRACE_OLD_GOV="" + while [ $i != 9999 ] ; do + temp="` cat /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor 2>/dev/null`" + if [ "$temp" == "" ] ; then + i=9999 + else + let i=$i+1 + FTRACE_OLD_GOV="$FTRACE_OLD_GOV $temp" + fi + done + + echo "Set CPUFreq governor to [performance]" + i=0 + while [ $i != 9999 ] ; do + temp="` cat /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor 2>/dev/null`" + if [ "$temp" == "" ] ; then + i=9999 + else + echo performance > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor + let i=$i+1 + fi + done + fi + + mount -t debugfs none /sys/kernel/debug/ 2>/dev/null + get_uptime + FTRACE_START_MARKER=$RESULT + + echo "Start FTrace..." + $TRACE_CMD_EXE reset + $TRACE_CMD_EXE start -b $CONFIG_FTRACE_BUFFER_SIZE $CONFIG_FTRACE_EVENTS + echo $FTRACE_START_MARKER > /sys/kernel/debug/tracing/trace_marker + echo "Tracing started @ $FTRACE_START_MARKER" } ftrace_stop() { - RESTORE_GOVERNOR=${1:-1} - - $TRACE_CMD_EXE stop - - get_uptime - ftrace_stop_start=$RESULT - echo "Tracing stopped" - - rm $FTRACE_FILE 2>/dev/null - if [ "$CONFIG_FTRACE_BINARY" == "n" ] ; then - echo "Extracting ASCII trace buffer..." - $TRACE_CMD_EXE show > $FTRACE_FILE 2>/dev/null - else - echo "Extracting BINARY trace buffer..." - $TRACE_CMD_EXE extract -o $FTRACE_FILE 2>/dev/null - fi - get_uptime - ftrace_extract_done=$RESULT - echo "Trace analysis from $ftrace_stop_start to $ftrace_extract_done" - - if [ $RESTORE_GOVERNOR -eq 1 ]; then - echo "Restore CPUFreq governors..." - i=0 - for value in $FTRACE_OLD_GOV ; do - echo $value > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor - let i=$i+1 - done - fi - - copy_trace_events + RESTORE_GOVERNOR=${1:-1} + + $TRACE_CMD_EXE stop + + get_uptime + ftrace_stop_start=$RESULT + echo "Tracing stopped" + + rm $FTRACE_FILE 2>/dev/null + if [ "$CONFIG_FTRACE_BINARY" == "n" ] ; then + echo "Extracting ASCII trace buffer..." + $TRACE_CMD_EXE show > $FTRACE_FILE 2>/dev/null + else + echo "Extracting BINARY trace buffer..." + $TRACE_CMD_EXE extract -o $FTRACE_FILE 2>/dev/null + fi + get_uptime + ftrace_extract_done=$RESULT + echo "Trace analysis from $ftrace_stop_start to $ftrace_extract_done" + + if [ $RESTORE_GOVERNOR -eq 1 ]; then + echo "Restore CPUFreq governors..." + i=0 + for value in $FTRACE_OLD_GOV ; do + echo $value > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor + let i=$i+1 + done + fi + + copy_trace_events } ftrace_check() { - get_uptime - ftrace_check_start=$RESULT - export TRACE_EVENTS_PATH - commandline="TRACE_EVENTS_PATH=$FTRACE_EVENTS" - export EXPECTED_TIME_IN_END_STATE_MS - commandline="$commandline EXPECTED_TIME_IN_END_STATE_MS=$EXPECTED_TIME_IN_END_STATE_MS" - export EXPECTED_CHANGE_TIME_MS_MIN - commandline="$commandline EXPECTED_CHANGE_TIME_MS_MIN=$EXPECTED_CHANGE_TIME_MS_MIN" - export EXPECTED_CHANGE_TIME_MS_MAX - commandline="$commandline EXPECTED_CHANGE_TIME_MS_MAX=$EXPECTED_CHANGE_TIME_MS_MAX" - export START_LITTLE - commandline="$commandline START_LITTLE=$START_LITTLE" - export START_LITTLE_PRIORITY - commandline="$commandline START_LITTLE_PRIORITY=$START_LITTLE_PRIORITY" - export START_BIG - commandline="$commandline START_BIG=$START_BIG" - export START_BIG_PRIORITY - commandline="$commandline START_BIG_PRIORITY=$START_BIG_PRIORITY" - export END_LITTLE - commandline="$commandline END_LITTLE=$END_LITTLE" - export END_LITTLE_PRIORITY - commandline="$commandline END_LITTLE_PRIORITY=$END_LITTLE_PRIORITY" - export END_BIG - commandline="$commandline END_BIG=$END_BIG" - export END_BIG_PRIORITY - commandline="$commandline END_BIG_PRIORITY=$END_BIG_PRIORITY" - export FTRACE_START_MARKER - commandline="$commandline FTRACE_START_MARKER=$FTRACE_START_MARKER" - export DISCARD_TIME_MS - commandline="$commandline DISCARD_TIME_MS=$DISCARD_TIME_MS" - export CPU_FAST - commandline="$commandline CPU_FAST=$CPU_FAST" - export CPU_SLOW - commandline="$commandline CPU_SLOW=$CPU_SLOW" - commandline="$commandline $FTRACE_ANALYZER_EXE -l $1 -t $FTRACE_FILE" - echo "# $commandline" - if [ "$CONFIG_FTRACE_BINARY" == "y" ] ; then - $TRACE_CMD_EXE report -i $FTRACE_FILE > trace.txt 2>/dev/null - $FTRACE_ANALYZER_EXE -l $1 -t trace.txt - RESULT0=$? - rm trace.txt - else - $FTRACE_ANALYZER_EXE -l $1 -t $FTRACE_FILE - RESULT0=$? - fi - get_uptime - ftrace_check_done=$RESULT - echo "Trace analysis run from $ftrace_check_start to $ftrace_check_done" - - # remove ftrace files if it was a success to limit - # space used on sdcard. - if [ "x$CONFIG_FTRACE_CLEANUP" == "xy" -a "$RESULT0" == "0" ] ; then - rm $FTRACE_FILE - else - gzip $FTRACE_FILE - fi - RESULT=$RESULT0 + get_uptime + ftrace_check_start=$RESULT + export TRACE_EVENTS_PATH + commandline="TRACE_EVENTS_PATH=$FTRACE_EVENTS" + export EXPECTED_TIME_IN_END_STATE_MS + commandline="$commandline EXPECTED_TIME_IN_END_STATE_MS=$EXPECTED_TIME_IN_END_STATE_MS" + export EXPECTED_CHANGE_TIME_MS_MIN + commandline="$commandline EXPECTED_CHANGE_TIME_MS_MIN=$EXPECTED_CHANGE_TIME_MS_MIN" + export EXPECTED_CHANGE_TIME_MS_MAX + commandline="$commandline EXPECTED_CHANGE_TIME_MS_MAX=$EXPECTED_CHANGE_TIME_MS_MAX" + export START_LITTLE + commandline="$commandline START_LITTLE=$START_LITTLE" + export START_LITTLE_PRIORITY + commandline="$commandline START_LITTLE_PRIORITY=$START_LITTLE_PRIORITY" + export START_BIG + commandline="$commandline START_BIG=$START_BIG" + export START_BIG_PRIORITY + commandline="$commandline START_BIG_PRIORITY=$START_BIG_PRIORITY" + export END_LITTLE + commandline="$commandline END_LITTLE=$END_LITTLE" + export END_LITTLE_PRIORITY + commandline="$commandline END_LITTLE_PRIORITY=$END_LITTLE_PRIORITY" + export END_BIG + commandline="$commandline END_BIG=$END_BIG" + export END_BIG_PRIORITY + commandline="$commandline END_BIG_PRIORITY=$END_BIG_PRIORITY" + export FTRACE_START_MARKER + commandline="$commandline FTRACE_START_MARKER=$FTRACE_START_MARKER" + export DISCARD_TIME_MS + commandline="$commandline DISCARD_TIME_MS=$DISCARD_TIME_MS" + export CPU_FAST + commandline="$commandline CPU_FAST=$CPU_FAST" + export CPU_SLOW + commandline="$commandline CPU_SLOW=$CPU_SLOW" + commandline="$commandline $FTRACE_ANALYZER_EXE -l $1 -t $FTRACE_FILE" + echo "# $commandline" + if [ "$CONFIG_FTRACE_BINARY" == "y" ] ; then + $TRACE_CMD_EXE report -i $FTRACE_FILE > trace.txt 2>/dev/null + $FTRACE_ANALYZER_EXE -l $1 -t trace.txt + RESULT0=$? + rm trace.txt + else + $FTRACE_ANALYZER_EXE -l $1 -t $FTRACE_FILE + RESULT0=$? + fi + get_uptime + ftrace_check_done=$RESULT + echo "Trace analysis run from $ftrace_check_start to $ftrace_check_done" + + # remove ftrace files if it was a success to limit + # space used on sdcard. + if [ "x$CONFIG_FTRACE_CLEANUP" == "xy" -a "$RESULT0" == "0" ] ; then + rm $FTRACE_FILE + else + gzip $FTRACE_FILE + fi + RESULT=$RESULT0 } get_task_pid() { - TRACE=$1 - TASK_NAME=$2 + TRACE=$1 + TASK_NAME=$2 - TASK=`awk -v PATTERN="$TASK_NAME-([0-9]+)" '$1 ~ PATTERN {print $1; exit 0;}' $TRACE` - TASK_PID=${TASK/${TASK_NAME}-/} + TASK=`awk -v PATTERN="$TASK_NAME-([0-9]+)" '$1 ~ PATTERN {print $1; exit 0;}' $TRACE` + TASK_PID=${TASK/${TASK_NAME}-/} - echo "Found task [$TASK_NAME] PID: $TASK_PID" - RESULT=$TASK_PID + echo "Found task [$TASK_NAME] PID: $TASK_PID" + RESULT=$TASK_PID } ftrace_check_tasks() { - get_uptime - export TRACE_TASKS - - # Generate TXT file required for analysis - if [ "$CONFIG_FTRACE_BINARY" == "y" ] ; then - $TRACE_CMD_EXE report -i $FTRACE_FILE > trace.txt 2>/dev/null - mv $FTRACE_FILE $FTRACE_FILE.bin - mv trace.txt $FTRACE_FILE - fi - - echo "Extracting tasks PIDs..." - for TASK in $TRACE_TASKS; do - get_task_pid $FTRACE_FILE $TASK - TASK_PID=$RESULT - PIDS+="$TASK_PID," - done - - echo "Computing CPUs usages for PIDs: $PIDS" - export PID=$PIDS - commandline="PID=$PID" - export CPUS_MASK - commandline="$commandline CPUS_MASK=$CPUS_MASK" - export USAGE_MIN - commandline="$commandline USAGE_MIN=$USAGE_MIN" - export USAGE_MAX - commandline="$commandline USAGE_MAX=$USAGE_MAX" - export TIME_MIN - commandline="$commandline TIME_MIN=$TIME_MIN" - export TIME_MAX - commandline="$commandline TIME_MAX=$TIME_MAX" - echo "# $commandline" - $FTRACE_ANALYZER_EXE -l libprocess_matrix.so.1.0.0 -t $FTRACE_FILE - RESULT0=$? - - # Recover original binary file - if [ "$CONFIG_FTRACE_BINARY" == "y" ] ; then - rm $FTRACE_FILE - mv $FTRACE_FILE.bin $FTRACE_FILE - fi - - # remove ftrace files if it was a success to limit - # space used on sdcard. - if [ "x$CONFIG_FTRACE_CLEANUP" == "xy" -a "$RESULT0" == "0" ] ; then - rm $FTRACE_FILE - else - gzip $FTRACE_FILE - fi - - # Return test result to testrunner - RESULT=$RESULT0 + get_uptime + export TRACE_TASKS + + # Generate TXT file required for analysis + if [ "$CONFIG_FTRACE_BINARY" == "y" ] ; then + $TRACE_CMD_EXE report -i $FTRACE_FILE > trace.txt 2>/dev/null + mv $FTRACE_FILE $FTRACE_FILE.bin + mv trace.txt $FTRACE_FILE + fi + + echo "Extracting tasks PIDs..." + for TASK in $TRACE_TASKS; do + get_task_pid $FTRACE_FILE $TASK + TASK_PID=$RESULT + PIDS+="$TASK_PID," + done + + echo "Computing CPUs usages for PIDs: $PIDS" + export PID=$PIDS + commandline="PID=$PID" + export CPUS_MASK + commandline="$commandline CPUS_MASK=$CPUS_MASK" + export USAGE_MIN + commandline="$commandline USAGE_MIN=$USAGE_MIN" + export USAGE_MAX + commandline="$commandline USAGE_MAX=$USAGE_MAX" + export TIME_MIN + commandline="$commandline TIME_MIN=$TIME_MIN" + export TIME_MAX + commandline="$commandline TIME_MAX=$TIME_MAX" + echo "# $commandline" + $FTRACE_ANALYZER_EXE -l libprocess_matrix.so.1.0.0 -t $FTRACE_FILE + RESULT0=$? + + # Recover original binary file + if [ "$CONFIG_FTRACE_BINARY" == "y" ] ; then + rm $FTRACE_FILE + mv $FTRACE_FILE.bin $FTRACE_FILE + fi + + # remove ftrace files if it was a success to limit + # space used on sdcard. + if [ "x$CONFIG_FTRACE_CLEANUP" == "xy" -a "$RESULT0" == "0" ] ; then + rm $FTRACE_FILE + else + gzip $FTRACE_FILE + fi + + # Return test result to testrunner + RESULT=$RESULT0 } diff --git a/Runner/utils/functestlib.sh b/Runner/utils/functestlib.sh index 64db3503..623d3792 100755 --- a/Runner/utils/functestlib.sh +++ b/Runner/utils/functestlib.sh @@ -1,18 +1,18 @@ -# +# # Import test suite definitions -source /var/Runner/init_env +. $(pwd)/init_env #import platform -source $TOOLS/platform.sh +. $TOOLS/platform.sh -__RUNNER_SUITES_DIR="/var/Runner/suites" +__RUNNER_SUITES_DIR="$(pwd)/suites" __RUNNER_UTILS_BIN_DIR="/var/common" #This function used for test logging log() { local level="$1" - shift + shift # echo "$(date '+%Y-%m-%d %H:%M:%S') - $message" | tee -a /var/test_framework.log - echo "[$level] $(date '+%Y-%m-%d %H:%M:%S') - $*" | tee -a /var/test_output.log + echo "[$level] $(date '+%Y-%m-%d %H:%M:%S') - $*" | tee -a /var/test_output.log } # Find test case path by name find_test_case_by_name() { @@ -44,7 +44,7 @@ check_dependencies() { log_error "Exiting due to missing dependencies." exit 1 else - log_pass "Test related dependencies are present." + log_pass "Test related dependencies are present." fi } diff --git a/Runner/utils/platform.sh b/Runner/utils/platform.sh index 4427a44f..e5b59bd3 100755 --- a/Runner/utils/platform.sh +++ b/Runner/utils/platform.sh @@ -1,11 +1,11 @@ # Detect Android userland ANDROID_PATH=/system/build.prop if [ -f $ANDROID_PATH ]; then - ANDROID=1 - SHELL_CMD=sh + ANDROID=1 + SHELL_CMD=sh else - ANDROID=0 - SHELL_CMD=bash + ANDROID=0 + SHELL_CMD=bash fi function pidkiller() diff --git a/Runner/utils/send-to-lava.sh b/Runner/utils/send-to-lava.sh new file mode 100644 index 00000000..df5f22ef --- /dev/null +++ b/Runner/utils/send-to-lava.sh @@ -0,0 +1,55 @@ +#Copyright: 2016-2019 Linaro Limited +#SPDX-License-Identifier: GPL-2.0-only + +#!/bin/sh + +RESULT_FILE="$1" + +command -v lava-test-case > /dev/null 2>&1 +lava_test_case="$?" +command -v lava-test-set > /dev/null 2>&1 +lava_test_set="$?" + +if [ -f "${RESULT_FILE}" ]; then + while read -r line; do + if echo "${line}" | grep -iq -E ".* +(pass|fail|skip|unknown)$"; then + test="${line%% *}" + result="${line##* }" + + if [ "${lava_test_case}" -eq 0 ]; then + lava-test-case "${test}" --result "${result}" + else + echo "" + fi + elif echo "${line}" | grep -iq -E ".*+ (pass|fail|skip|unknown)+ .*+"; then + test="$(echo "${line}" | awk '{print $1}')" + result="$(echo "${line}" | awk '{print $2}')" + measurement="$(echo "${line}" | awk '{print $3}')" + units="$(echo "${line}" | awk '{print $4}')" + + if [ "${lava_test_case}" -eq 0 ]; then + if [ -n "${units}" ]; then + lava-test-case "${test}" --result "${result}" --measurement "${measurement}" --units "${units}" + else + lava-test-case "${test}" --result "${result}" --measurement "${measurement}" + fi + else + echo "" + fi + elif echo "${line}" | grep -iq -E "^lava-test-set.*"; then + test_set_status="$(echo "${line}" | awk '{print $2}')" + test_set_name="$(echo "${line}" | awk '{print $3}')" + if [ "${lava_test_set}" -eq 0 ]; then + lava-test-set "${test_set_status}" "${test_set_name}" + else + if [ "${test_set_status}" = "start" ]; then + echo "" + else + echo "" + fi + fi + fi + done < "${RESULT_FILE}" +else + echo "WARNING: result file is missing!" +fi diff --git a/common/src/Reboot/Simple_reboot.c b/common/src/Reboot/Simple_reboot.c deleted file mode 100755 index ad1ebeab..00000000 --- a/common/src/Reboot/Simple_reboot.c +++ /dev/null @@ -1,127 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#define HEALTH_DIR "/var/reboot_health" -#define LOG_FILE "/var/reboot_health/reboot_health.log" -#define SERIAL_PORT "/dev/ttyS0" - -// Function to get the current timestamp -void get_timestamp(char *buffer, size_t size) { - time_t now = time(NULL); - struct tm *t = localtime(&now); - strftime(buffer, size, "%Y-%m-%d %H:%M:%S", t); -} - -// Function to log messages with a specified level -void log_message(const char *level, const char *message) { - char timestamp[64]; - get_timestamp(timestamp, sizeof(timestamp)); - - // Log to file - FILE *log = fopen(LOG_FILE, "a"); - if (log) { - fprintf(log, "[%s] [%s] %s\n", timestamp, level, message); - fclose(log); - } - - // Log to serial port (for visibility) - FILE *serial = fopen(SERIAL_PORT, "w"); - if (serial) { - fprintf(serial, "[%s] [%s] %s\n", timestamp, level, message); - fclose(serial); - } -} - -// Helper functions for logging -void log_info(const char *message) { log_message("INFO", message); } -void log_pass(const char *message) { log_message("PASS", message); } -void log_fail(const char *message) { log_message("FAIL", message); } -void log_error(const char *message) { log_message("ERROR", message); } - -// Check if the system has recently rebooted by reading uptime -void check_system_reboot() { - FILE *fp; - char buffer[128]; - unsigned long uptime = 0; - - fp = fopen("/proc/uptime", "r"); - if (fp == NULL) { - log_error("Failed to read /proc/uptime."); - exit(1); - } - fscanf(fp, "%s", buffer); - fclose(fp); - - uptime = strtol(buffer, NULL, 10); // Uptime in seconds - - if (uptime < 300) { // If uptime is less than 5 minutes, assume the system has rebooted recently - log_info("System has rebooted recently (uptime < 300 seconds)."); - } else { - log_info("System uptime is normal (no recent reboot detected)."); - } -} - -// Check if the system is running a valid shell (PID 1) -void check_shell_alive() { - FILE *fp = fopen("/proc/1/comm", "r"); - if (!fp) { - log_fail("Cannot open /proc/1/comm. System critical error."); - exit(1); - } - - char buf[64] = {0}; - if (!fgets(buf, sizeof(buf), fp)) { - fclose(fp); - log_fail("Failed to read PID 1 comm."); - exit(1); - } - fclose(fp); - - buf[strcspn(buf, "\n")] = 0; // Remove trailing newline - - if (strstr(buf, "init") || strstr(buf, "systemd") || strstr(buf, "busybox")) { - char msg[128]; - snprintf(msg, sizeof(msg), "Booted successfully with PID1 -> %s", buf); - log_pass(msg); // Log PASS - } else { - char msg[128]; - snprintf(msg, sizeof(msg), "Boot failed. Unexpected PID1: %s", buf); - log_fail(msg); // Log FAIL - - log_info("Attempting reboot now..."); - sync(); - reboot(RB_AUTOBOOT); - } -} - -// Create the directory if it doesn't exist -int create_directory_if_not_exists(const char *dir_path) { - struct stat st = {0}; - if (stat(dir_path, &st) == -1) { - if (mkdir(dir_path, 0755) == -1) { - log_error("Failed to create directory /var/reboot_health."); - return -1; - } - log_info("Created directory /var/reboot_health."); - } - return 0; -} - -int main() { - // Ensure the directory exists before proceeding - if (create_directory_if_not_exists(HEALTH_DIR) != 0) { - log_error("Exiting due to failure in creating directory."); - return 1; // Directory creation failed - } - - check_system_reboot(); // Check if the system has recently rebooted - check_shell_alive(); // Check if the system shell (PID 1) is alive and healthy - - log_info("Reboot health check completed."); - return 0; -} diff --git a/common/src/Reboot/reboot_health_check.c b/common/src/Reboot/reboot_health_check.c deleted file mode 100755 index a264c438..00000000 --- a/common/src/Reboot/reboot_health_check.c +++ /dev/null @@ -1,124 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#define LOG_DIR "/var/reboot_health" -#define LOG_FILE "/var/reboot_health/reboot_health.log" -#define RESULT_FILE "/var/reboot_health/test_result.txt" // Separate result file for CI/CD - -// Function to check if the system rebooted (log file exists) -int check_system_rebooted() { - FILE *file = fopen(LOG_FILE, "r"); - if (file == NULL) { - return 0; // No log file means no reboot has occurred - } - fclose(file); - return 1; // Log file exists, system has rebooted -} - -// Function to log the result of the health check -void log_health_check(int status) { - FILE *log_file = fopen(LOG_FILE, "a"); - if (log_file == NULL) { - perror("Failed to open log file"); - exit(1); - } - - time_t now = time(NULL); - char *time_str = ctime(&now); - time_str[strlen(time_str) - 1] = '\0'; // Remove the newline character from ctime's output - - if (status) { - fprintf(log_file, "[%s] PASS: System rebooted successfully.\n", time_str); - } else { - fprintf(log_file, "[%s] FAIL: System did not reboot successfully.\n", time_str); - } - - fclose(log_file); -} - -// Function to write a result (PASS/FAIL) for CI/CD into a separate file -void write_result_for_cicd(int status) { - FILE *result_file = fopen(RESULT_FILE, "a"); - if (result_file == NULL) { - perror("Failed to open result file"); - exit(1); - } - - time_t now = time(NULL); - char *time_str = ctime(&now); - time_str[strlen(time_str) - 1] = '\0'; // Remove the newline character - - if (status) { - fprintf(result_file, "[%s] PASS\n", time_str); - } else { - fprintf(result_file, "[%s] FAIL\n", time_str); - } - - fclose(result_file); -} - -// Function to ensure the log directory exists -void create_log_directory() { - if (access(LOG_DIR, F_OK) == -1) { - if (mkdir(LOG_DIR, 0755) != 0) { - perror("Failed to create log directory"); - exit(1); - } - } -} - -// Function to check if the log and result files exist, create them if not -void ensure_files_exist() { - // Create log file if not exists - FILE *log_file = fopen(LOG_FILE, "a"); - if (log_file == NULL) { - perror("Failed to open log file"); - exit(1); - } - fclose(log_file); // Close after checking/creating the file - - // Create result file if not exists - FILE *result_file = fopen(RESULT_FILE, "w"); - if (result_file == NULL) { - perror("Failed to open result file"); - exit(1); - } - fclose(result_file); // Close after checking/creating the file -} - -// Watchdog timer simulation -void watchdog_timer() { - int counter = 0; - while (1) { - sleep(5); // Check every 5 seconds - - counter++; - - if (check_system_rebooted()) { - log_health_check(1); // Log success if system rebooted - write_result_for_cicd(1); // Write pass to CI/CD result file - break; // Exit the loop after success - } - - if (counter >= 12) { // Timeout after 1 minute - log_health_check(0); // Log failure if no reboot detected - write_result_for_cicd(0); // Write fail to CI/CD result file - break; // Exit the loop after failure - } - } -} - -int main() { - // Ensure the necessary directories and files exist - create_log_directory(); - ensure_files_exist(); - - // Start the watchdog timer - watchdog_timer(); - - return 0; -}