summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkaizhangNV <149626564+kaizhangNV@users.noreply.github.com>2024-09-10 17:03:25 -0500
committerGitHub <noreply@github.com>2024-09-10 15:03:25 -0700
commit9fd53811651004903eaf0cbcae712a70304ea0b1 (patch)
treeb222e3d65fd25098d64c4d80aa604ab8d25bb1f3
parentd33fad88b8b0c796bb48dd8be4cc04d4e8390558 (diff)
remove 'test-record-replay.sh' (#5057)
Forget removing this the script for testing record-replay. The test is already integrated to slang-test.
-rwxr-xr-xtest-record-replay.sh147
1 files changed, 0 insertions, 147 deletions
diff --git a/test-record-replay.sh b/test-record-replay.sh
deleted file mode 100755
index 2faabe954..000000000
--- a/test-record-replay.sh
+++ /dev/null
@@ -1,147 +0,0 @@
-#!/usr/bin/env bash
-
-RED='\033[0;31m'
-Green='\033[0;32m'
-NC='\033[0m'
-matchPattern="entrypoint: [0-9]+, target: [0-9]+, hash: [0-9a-fA-F]+"
-
-getHash()
-{
- matchedLine=$1
- local -n outputVar=$2
-
- entrypointIdx=$(echo $matchedLine | grep -oE "entrypoint: [0-9]+" | grep -oE "[0-9]+")
- targetIdx=$(echo $matchedLine | grep -oE "target: [0-9]+" | grep -oE "[0-9]+")
- hashCode=$(echo $matchedLine | grep -oE "hash: .*" | grep -oE ": [0-9a-fA-F]+" | grep -oE "[0-9a-fA-F]+")
-
- outputVar="$entrypointIdx-$targetIdx-$hashCode"
-}
-
-log()
-{
- msg=$1
- color=$2
- printf "${color}$1${NC}\n"
-}
-
-parseStandardOutput()
-{
- local -n resultArray=$1
- lines=$2
-
- for line in "${lines[@]}"
- do
- matchLine=$(echo $line | grep -oE "$matchPattern")
-
- if [ -n "$matchLine" ]; then
- result=""
- getHash "$matchLine" result
-
- if [ -n "$result" ]; then
- resultArray+=("$result")
- fi
- fi
- done
-}
-
-resultCheck()
-{
- local -n inExpectedResults=$1
- local -n inReplayResults=$2
- local -n outFailedResults=$3
-
- found=""
- for expectedResult in ${inExpectedResults[@]}; do
-
- for replayResult in ${inReplayResults[@]}; do
- if [ "$replayResult" == "$expectedResult" ]; then
- found="1"
- fi
- done
-
- if [ -z "$found" ]; then
- echo "$expectedResult is not Found in replay"
- outFailedResults+=("$expectedResult")
- else
- echo "$expectedResult is Found in replay"
- fi
- done
-}
-
-# TODO: Add more test commands here in this array
-testCommands=("./build/Debug/bin/hello-world" "./build/Debug/bin/triangle")
-
-# Enable hash code generation for the test such that
-# we can have something to compare with replaying the test
-argsToEnableHashCode="--test-mode"
-
-declare -A testStats
-
-for ((i = 0; i < ${#testCommands[@]}; i++))
-do
- testCommand=${testCommands[$i]}
- echo "Start running test: $testCommand"
-
- # Run the test executable
- export SLANG_RECORD_LAYER=1
- mapfile -t lines < <(${testCommand} ${argsToEnableHashCode})
- unset SLANG_RECORD_LAYER
-
- # parse the output from stdout
- expectedResults=()
- parseStandardOutput expectedResults "${lines[@]}"
-
- echo "Expected Results: ${expectedResults[@]}"
- if [ ${#expectedResults[@]} -eq 0 ]; then
- log "No expected results found" $RED
- rm -rf ./slang-record/*
- continue
- fi
-
- # Replay the record file
- export SLANG_RECORD_LOG_LEVEL=3
- replayTestCommand="./build/Debug/bin/slang-replay ./slang-record/*.cap"
- echo "Start replaying the test ..."
- mapfile -t lines < <(${replayTestCommand})
- unset SLANG_RECORD_LOG_LEVEL
-
- # parse the output from stdout
- replayResults=()
- parseStandardOutput replayResults "${lines[@]}"
-
- echo "Replay Results: ${replayResults[@]}"
- if [ ${#replayResults[@]} -eq 0 ]; then
- log "No replay results found" $RED
- rm -rf ./slang-record/*
- continue
- fi
-
- # Check the results
- failedResults=()
- resultCheck expectedResults replayResults failedResults
-
- rm -rf ./slang-record/*
-
- if [ ${#failedResults[@]} -eq 0 ]; then
- testStats[$testCommand]="PASSED"
- else
- testStats[$testCommand]="FAILED"
- fi
- printf "\n"
-done
-
-for testName in "${!testStats[@]}"
-do
- if [ "${testStats[$testName]}" == "PASSED" ]; then
- log "$testName: PASSED" $Green
- else
- log "$testName: FAILED" $RED
- fi
-done
-
-# Notify the CI if any of the tests failed
-if [ ${#testStats[@]} -eq 0 ]; then
- exit 0
-else
- exit 1
-fi