Просмотр исходного кода

ncd: tests: add run_tests script

ambrop7 13 лет назад
Родитель
Сommit
4e56484541
1 измененных файлов с 38 добавлено и 0 удалено
  1. 38 0
      ncd/tests/run_tests

+ 38 - 0
ncd/tests/run_tests

@@ -0,0 +1,38 @@
+#!/bin/sh
+
+NCD=$1
+USE_VALGRIND=$2
+
+if [[ -z $NCD ]] || [[ -n $USE_VALGRIND && $USE_VALGRIND != use_valgrind ]]; then
+	echo "Usage: $0 <ncd_command> [use_valgrind]"
+	exit 1
+fi
+
+if [[ ! -e ./run_tests ]]; then
+	echo "Must run from the tests directory"
+	exit 1
+fi
+
+failed=0
+
+for file in ./*.ncd; do
+	echo "Running: $file"
+	if [[ $USE_VALGRIND = use_valgrind ]]; then
+		valgrind --error-exitcode=1 --leak-check=full "$NCD" --loglevel none --config-file "$file"
+	else
+		"$NCD" --loglevel none --config-file "$file"
+	fi
+	res=$?
+	if [[ ! $res -eq 0 ]]; then
+		echo "FAILED"
+		let failed+=1
+	fi
+done
+
+if [[ $failed -gt 0 ]]; then
+	echo "$failed tests FAILED"
+	exit 1
+fi
+
+echo "all tests passed"
+exit 0