@@ -128,51 +128,69 @@ endif
128128check-asan: $(TESTNAME)
129129ifneq (,$(findstring $(GPU_W_FEATURES),$(SUPPORTED)))
130130ifeq (,$(findstring $(GPU_W_FEATURES),$(UNSUPPORTED)))
131- path=`pwd`; \
132- base=`basename $$path`; \
133- ( \
134- flock -e 9 && echo "" >> ../check-smoke-asan.txt; \
135- declare -A CmdStatus; \
136- pipeline="$(RUNENV) $(SMOKE_TIMEOUT) $(RUNPROF) $(RUNPROF_FLAGS) $(CHECK_COMMAND) > /dev/null 2>&1"; \
137- $(RUNENV) $(SMOKE_TIMEOUT) $(RUNPROF) $(RUNPROF_FLAGS) $(CHECK_COMMAND) > /dev/null 2>&1; \
138- pstat=($${PIPESTATUS[@]}); \
139- function GetPipedCmdStatus() { \
140- Cmd="$$2"; \
141- CmdRunIndex="$$3"; \
142- CmdRunIndexList=($$(echo $$1 | awk -F'|' '{for(i=1;i<=NF;i++) {gsub(/^[ \t]+|[ \t]+$$/, "", $$i); print $$i}}' | awk -v Cmd_Pattern="$$Cmd " '$$0~Cmd_Pattern {print NR}')); \
143- for CmdIndex in "$${CmdRunIndexList[@]}"; do \
144- if [ -v CmdStatus["$$Cmd"] ]; then \
145- ArrString=$${CmdStatus["$$Cmd"]}; \
146- ArrString+=",$${pstat[$$CmdIndex-1]}"; \
147- CmdStatus["$$Cmd"]=$${ArrString}; \
148- else \
149- NewArrString=$${pstat[$$CmdIndex-1]}; \
150- CmdStatus["$$Cmd"]=$${NewArrString}; \
151- fi; \
152- done; \
153- if [ -v CmdStatus[$$Cmd] ] && [ $$CmdRunIndex -gt 0 ];then \
154- IFS=',' read -ra CmdStatusList <<< "$${CmdStatus[$$Cmd]}"; \
155- return $${CmdStatusList["$$CmdRunIndex"-1]}; \
156- fi; \
157- }; \
158- GetPipedCmdStatus "$$pipeline" "$(TESTNAME)" "1"; \
159- test_status=$$?; \
160- GetPipedCmdStatus "$$pipeline" "FileCheck" "1"; \
161- filecheck_status=$$?; \
162- echo "$$test_status" > TEST_STATUS; \
163- echo "$$filecheck_status" > FILECHECK_STATUS; \
164- echo $$base $$test_num return code: $$test_status >> ../check-smoke-asan.txt; \
165- echo "" >> ../check-smoke-asan.txt; \
166- if [ $$filecheck_status -eq 0 ]; then echo $$base $$test_num >> ../passing-tests.txt; \
167- else echo $$base $$test_num >> ../failing-tests.txt; fi; \
168- )9>../lockfile;
131+ path=`pwd`; \
132+ base=`basename $$path`; \
133+ ( \
134+ flock -e 9 && echo "" >> ../check-smoke-asan.txt; \
135+ # CmdStatus: Associative Container which keeps track of execution status of any command in the pipeline. \
136+ declare -A CmdStatus; \
137+ # GetPipedCmdStatus: Function which on demand populates the CmdStatus container with execution status values of each command executing in a given input pipeline. \
138+ # param_1: pipeline as string. \
139+ # param_2: pipestatus computed from PIPESTATUS as array. \
140+ # param_3: Cmd Name as string. \
141+ # param_4: CmdRunIndex of Cmd as positive integer. \
142+ function GetPipedCmdStatus() { \
143+ # pstat: Piped command status list. \
144+ local -n pstat=$$2; \
145+ # Cmd: Command Name \
146+ Cmd="$$3"; \
147+ # CmdRunIndex: Index value of Cmd executing in the pipeline. \
148+ # Ex. pipeline = "Cmd1 | Cmd2 | Cmd3 | Cmd1 | Cmd4 | Cmd3" \
149+ # CmdRunIndex of Cmd1(First Time): 1 \
150+ # CmdRunIndex of Cmd2(First Time): 1 \
151+ # CmdRunIndex of Cmd1(Second Time): 4 \
152+ CmdRunIndex="$$4"; \
153+ # CmdRunIndexList: Index List of each Cmd. \
154+ # Ex. pipeline = "Cmd1 | Cmd2 | Cmd1 | Cmd3" \
155+ # CmdRunIndexList of Cmd1: (1,3) \
156+ CmdRunIndexList=($$(echo $$1 | awk -F'|' '{for(i=1;i<=NF;i++) {gsub(/^[ \t]+|[ \t]+$$/, "", $$i); print $$i}}' | awk -v Cmd_Pattern="$$Cmd " '$$0~Cmd_Pattern {print NR}')); \
157+ for CmdIndex in "$${CmdRunIndexList[@]}"; do \
158+ if [ -v CmdStatus["$$Cmd"] ]; then \
159+ ArrString=$${CmdStatus["$$Cmd"]}; \
160+ ArrString+=",$${pstat[$$CmdIndex-1]}"; \
161+ CmdStatus["$$Cmd"]=$${ArrString}; \
162+ else \
163+ NewArrString=$${pstat[$$CmdIndex-1]}; \
164+ CmdStatus["$$Cmd"]=$${NewArrString}; \
165+ fi; \
166+ done; \
167+ if [ -v CmdStatus[$$Cmd] ] && [ $$CmdRunIndex -gt 0 ];then \
168+ IFS=',' read -ra CmdStatusList <<< "$${CmdStatus[$$Cmd]}"; \
169+ return $${CmdStatusList["$$CmdRunIndex"-1]}; \
170+ fi; \
171+ }; \
172+ pipeline="$(RUNENV) $(SMOKE_TIMEOUT) $(RUNPROF) $(RUNPROF_FLAGS) $(CHECK_COMMAND) > /dev/null 2>&1"; \
173+ $(RUNENV) $(SMOKE_TIMEOUT) $(RUNPROF) $(RUNPROF_FLAGS) $(CHECK_COMMAND) > /dev/null 2>&1; \
174+ pipestatus=($${PIPESTATUS[@]}); \
175+ GetPipedCmdStatus "$$pipeline" "pipestatus" "$(TESTNAME)" "1"; \
176+ test_status=$$?; \
177+ GetPipedCmdStatus "$$pipeline" "pipestatus" "FileCheck" "1"; \
178+ filecheck_status=$$?; \
179+ echo "$$test_status" > TEST_STATUS; \
180+ echo "$$filecheck_status" > FILECHECK_STATUS; \
181+ echo $$base $$test_num return code: $$test_status >> ../check-smoke-asan.txt; \
182+ echo "" >> ../check-smoke-asan.txt; \
183+ if [ $$filecheck_status -eq 0 ]; then echo $$base $$test_num >> ../passing-tests.txt; \
184+ else echo $$base $$test_num >> ../failing-tests.txt; fi; \
185+ )9>../lockfile;
169186else
170- @echo " $(SKIP_RUN_UNSUPPORTED)"
187+ @echo " $(SKIP_RUN_UNSUPPORTED)"
171188endif
172189else
173- @echo " $(SKIP_RUN_SUPPORTED)"
190+ @echo " $(SKIP_RUN_SUPPORTED)"
174191endif
175192
193+
176194# ----- Demo compile and link to object file
177195ifneq ($(TESTNAME), $(findstring $(TESTNAME),$(TESTNAMES_ALL)))
178196.PHONY: $(TESTNAME).o
0 commit comments