From: Jason Ish Date: Fri, 19 Jan 2018 20:23:25 +0000 (-0600) Subject: setup/check relative to output directory X-Git-Tag: suricata-6.0.4~516 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67dc512ddff52eb24ac83132b3ee1b12f63e5ea6;p=thirdparty%2Fsuricata-verify.git setup/check relative to output directory Run the setup and check phases relative to the output directory. --- diff --git a/run.py b/run.py index 1233cdb2f..1781b6b17 100755 --- a/run.py +++ b/run.py @@ -159,7 +159,7 @@ class StatsCheck: def run(self): stats = None - with open(os.path.join("output", "eve.json"), "r") as fileobj: + with open("eve.json", "r") as fileobj: for line in fileobj: event = json.loads(line) if event["event_type"] == "stats": @@ -177,7 +177,7 @@ class FilterCheck: self.config = config def run(self): - eve_json_path = os.path.join("output", "eve.json") + eve_json_path = "eve.json" if not os.path.exists(eve_json_path): raise TestError("%s does not exist" % (eve_json_path)) @@ -237,7 +237,7 @@ class TestRunner: subprocess.check_call( "%s" % setup[command], shell=True, - cwd=self.directory) + cwd=os.path.join(self.directory, "output")) def check_skip(self): if not "skip" in self.config: @@ -376,7 +376,7 @@ class TestRunner: def check(self): pdir = os.getcwd() - os.chdir(self.directory) + os.chdir(os.path.join(self.directory, "output")) try: if "checks" in self.config: for check in self.config["checks"]: @@ -398,14 +398,29 @@ class TestRunner: finally: os.chdir(pdir) - if not os.path.exists(os.path.join(self.directory, "check.sh")): + # Old style check script. + pdir = os.getcwd() + os.chdir(os.path.join(self.directory, "output")) + try: + if not os.path.exists(os.path.join(self.directory, "check.sh")): + return True + env = { + # The suricata source directory. + "SRCDIR": self.cwd, + "TZ": "UTC", + "TEST_DIR": self.directory, + "TOPDIR": TOPDIR, + "ASAN_OPTIONS": "detect_leaks=0", + } + r = subprocess.call( + [os.path.join(self.directory, "check.sh")], env=env) + if r != 0: + print("FAILED: verification failed") + return False return True - r = subprocess.call(["./check.sh"], cwd=self.directory) - if r != 0: - print("FAILED: verification failed") - return False - return True - + finally: + os.chdir(pdir) + def default_args(self): args = [ os.path.join(self.cwd, "src/suricata"), @@ -479,6 +494,7 @@ def check_deps(): return True def main(): + global TOPDIR if not check_deps(): return 1 @@ -494,8 +510,8 @@ def main(): parser.add_argument("patterns", nargs="*", default=[]) args = parser.parse_args() - topdir = os.path.abspath(os.path.dirname(sys.argv[0])) - + TOPDIR = os.path.abspath(os.path.dirname(sys.argv[0])) + skipped = 0 passed = 0 failed = 0 @@ -512,7 +528,7 @@ def main(): # Create a SuricataConfig object that is passed to all tests. suricata_config = SuricataConfig(get_suricata_version()) - tdir = os.path.join(topdir, "tests") + tdir = os.path.join(TOPDIR, "tests") if args.dir: tdir = os.path.abspath(args.dir) @@ -520,7 +536,7 @@ def main(): tests = [] for dirpath, dirnames, filenames in os.walk(tdir): # The top directory is not a test... - if dirpath == os.path.join(topdir, "tests"): + if dirpath == os.path.join(TOPDIR, "tests"): continue if dirpath == tdir: continue diff --git a/tests/alert-testmyids-not-established/test.yaml b/tests/alert-testmyids-not-established/test.yaml index ef1c26699..88e92bb66 100644 --- a/tests/alert-testmyids-not-established/test.yaml +++ b/tests/alert-testmyids-not-established/test.yaml @@ -5,7 +5,7 @@ requires: checks: - shell: - args: cat output/fast.log | wc -l | xargs + args: cat fast.log | wc -l | xargs expect: 1 - filter: diff --git a/tests/alert-testmyids/test.yaml b/tests/alert-testmyids/test.yaml index 9ac7277e6..b6ce41dc8 100644 --- a/tests/alert-testmyids/test.yaml +++ b/tests/alert-testmyids/test.yaml @@ -12,5 +12,5 @@ checks: # Check how many lines were logged to fast.log. - shell: - args: cat output/fast.log | wc -l | xargs + args: cat fast.log | wc -l | xargs expect: 1 diff --git a/tests/dnp3-dnp3_data-alert/check.sh b/tests/dnp3-dnp3_data-alert/check.sh index 7f4a0d584..ee2d0326b 100755 --- a/tests/dnp3-dnp3_data-alert/check.sh +++ b/tests/dnp3-dnp3_data-alert/check.sh @@ -1,9 +1,9 @@ #! /bin/sh -. ../../util/functions.sh +. ${TOPDIR}/util/functions.sh # Should have 4 DNP3 data match alerts. -n=$(grep "DNP3 Data match" output/eve.json | wc -l | xargs) +n=$(grep "DNP3 Data match" eve.json | wc -l | xargs) assert_eq 4 "$n" "bad event count" exit 0 diff --git a/tests/dnp3-dnp3_func-alert/check.sh b/tests/dnp3-dnp3_func-alert/check.sh index ae197aad2..8d16638d6 100755 --- a/tests/dnp3-dnp3_func-alert/check.sh +++ b/tests/dnp3-dnp3_func-alert/check.sh @@ -1,13 +1,13 @@ #! /bin/sh -. ../../util/functions.sh +. ${TOPDIR}/util/functions.sh # Should have one alert sid 1. -n=$(jq_count output/eve.json 'select(.alert.signature_id == 1)') +n=$(jq_count eve.json 'select(.alert.signature_id == 1)') assert_eq 1 "$n" "sig id 1" # Should have one alert sid 2. -n=$(jq_count output/eve.json 'select(.alert.signature_id == 2)') +n=$(jq_count eve.json 'select(.alert.signature_id == 2)') assert_eq 1 "$n" "sig id 1" exit 0 diff --git a/tests/dnp3/check.sh b/tests/dnp3/check.sh index ef0fcfaf7..baff318ec 100755 --- a/tests/dnp3/check.sh +++ b/tests/dnp3/check.sh @@ -1,8 +1,8 @@ #! /bin/sh -. ../../util/functions.sh +. ${TOPDIR}/util/functions.sh -n=$(jq_count output/eve.json 'select(.event_type == "dnp3")') +n=$(jq_count eve.json 'select(.event_type == "dnp3")') assert_eq 55 "$n" "bad dnp3 event count" exit 0 diff --git a/tests/dns-json-log/check.sh b/tests/dns-json-log/check.sh index 809c31f28..d833374da 100755 --- a/tests/dns-json-log/check.sh +++ b/tests/dns-json-log/check.sh @@ -1,21 +1,21 @@ #! /bin/sh # Expect 9 dns records. -n=$(cat output/dns.json | jq -c 'select(.event_type == "dns")' | wc -l | xargs) +n=$(cat dns.json | jq -c 'select(.event_type == "dns")' | wc -l | xargs) if test $n -ne 9; then echo "failed: expected 9 dns events, got $n" exit 1 fi # 4 are queries. -n=$(cat output/dns.json | jq -c 'select(.event_type == "dns") | select(.dns.type == "query")' | wc -l | xargs) +n=$(cat dns.json | jq -c 'select(.event_type == "dns") | select(.dns.type == "query")' | wc -l | xargs) if test $n -ne 4; then echo "failed: expected 4 dns queries, got $n" exit 1 fi # 4 are queries. -n=$(cat output/dns.json | jq -c 'select(.event_type == "dns") | select(.dns.type == "answer")' | wc -l | xargs) +n=$(cat dns.json | jq -c 'select(.event_type == "dns") | select(.dns.type == "answer")' | wc -l | xargs) if test $n -ne 5; then echo "failed: expected 5 dns answers, got $n" exit 1 diff --git a/tests/dns-tcp-multirequest-buffer-1/check.sh b/tests/dns-tcp-multirequest-buffer-1/check.sh index 8a27df75a..760512510 100755 --- a/tests/dns-tcp-multirequest-buffer-1/check.sh +++ b/tests/dns-tcp-multirequest-buffer-1/check.sh @@ -1,12 +1,12 @@ #! /bin/sh -count=$(cat output/eve.json | jq -c 'select(.dns.type=="query")' | wc -l | xargs) +count=$(cat eve.json | jq -c 'select(.dns.type=="query")' | wc -l | xargs) if [ "${count}" -ne 20 ]; then echo "error: expected 20 queries, got ${count}" exit 1 fi -count=$(cat output/eve.json | jq -c 'select(.dns.type=="answer")' | wc -l | xargs) +count=$(cat eve.json | jq -c 'select(.dns.type=="answer")' | wc -l | xargs) if [ "${count}" -ne 40 ]; then echo "error: expected 40 answers, got ${count}" exit 1 diff --git a/tests/dns-tcp-ts-gap/check.sh b/tests/dns-tcp-ts-gap/check.sh index b8f936265..d1544764f 100755 --- a/tests/dns-tcp-ts-gap/check.sh +++ b/tests/dns-tcp-ts-gap/check.sh @@ -1,10 +1,10 @@ #! /bin/sh -. ../../util/functions.sh +. ${TOPDIR}/util/functions.sh # As a request was missing, we should have 2 requests, but 26 # responses, as each request resulted in 12 responses. -log=./output/eve.json +log=./eve.json n=$(cat ${log} | \ jq -c 'select(.event_type == "dns") | select(.dns.type == "query")' | \ diff --git a/tests/dns-tcp-www-google-com/check.sh b/tests/dns-tcp-www-google-com/check.sh index 307cdc5d7..e3e3b7fbd 100755 --- a/tests/dns-tcp-www-google-com/check.sh +++ b/tests/dns-tcp-www-google-com/check.sh @@ -1,11 +1,11 @@ #! /bin/sh -. ../../util/functions.sh +. ${TOPDIR}/util/functions.sh # One DNS request. -n=$(jq_count output/eve.json 'select(.event_type == "dns") | select(.dns.type == "query")') +n=$(jq_count eve.json 'select(.event_type == "dns") | select(.dns.type == "query")') assert_eq 1 $n "dns requests" # 12 DNS responses. -n=$(jq_count output/eve.json 'select(.event_type == "dns") | select(.dns.type == "answer")') +n=$(jq_count eve.json 'select(.event_type == "dns") | select(.dns.type == "answer")') assert_eq 12 $n "dns responses" diff --git a/tests/dns-udp-dns-log-unanswered/check.sh b/tests/dns-udp-dns-log-unanswered/check.sh index 6bd3a34a3..851f928ca 100755 --- a/tests/dns-udp-dns-log-unanswered/check.sh +++ b/tests/dns-udp-dns-log-unanswered/check.sh @@ -1,12 +1,12 @@ #! /bin/sh -n=$(grep Query output/dns.log | wc -l | xargs) +n=$(grep Query dns.log | wc -l | xargs) if [ "$n" -ne 4 ]; then echo "expected 4 queries, found $n" exit 1 fi -n=$(grep Response output/dns.log | wc -l | xargs) +n=$(grep Response dns.log | wc -l | xargs) if [ "$n" -ne 4 ]; then echo "expected 4 responses, found $n" exit 1 diff --git a/tests/dns-udp-double-request-response/check.sh b/tests/dns-udp-double-request-response/check.sh index 1fd9f822c..d8f04ecf7 100755 --- a/tests/dns-udp-double-request-response/check.sh +++ b/tests/dns-udp-double-request-response/check.sh @@ -1,14 +1,14 @@ #! /bin/sh # Check queries. -c=$(cat output/eve.json | jq -c 'select(.dns.type == "query")' | wc -l | xargs) +c=$(cat eve.json | jq -c 'select(.dns.type == "query")' | wc -l | xargs) if [ "${c}" -ne 2 ]; then echo "error: expected 2 DNS queries, got ${c}" exit 1 fi # Check answer count. -c=$(cat output/eve.json | jq -c 'select(.dns.type == "answer")' | wc -l | xargs) +c=$(cat eve.json | jq -c 'select(.dns.type == "answer")' | wc -l | xargs) if [ "${c}" -ne 9 ]; then echo "error: expected 9 DNS answers, got ${c}" exit 1 diff --git a/tests/dns-udp-eve-log-aaaa-only/check.sh b/tests/dns-udp-eve-log-aaaa-only/check.sh index 16997d8c7..43b477d00 100755 --- a/tests/dns-udp-eve-log-aaaa-only/check.sh +++ b/tests/dns-udp-eve-log-aaaa-only/check.sh @@ -1,11 +1,11 @@ #! /bin/sh -. ../../util/functions.sh +. ${TOPDIR}/util/functions.sh -n=$(jq_count output/eve.json 'select(.dns.rrtype == "AAAA")') +n=$(jq_count eve.json 'select(.dns.rrtype == "AAAA")') assert_eq 2 $n "expected 2 aaaa records" -n=$(jq_count output/eve.json 'select(.dns.rrtype != "AAAA")') +n=$(jq_count eve.json 'select(.dns.rrtype != "AAAA")') assert_eq 0 $n "expected 0 non-aaaa records" exit 0 diff --git a/tests/dns-udp-eve-log-answer-only/check.sh b/tests/dns-udp-eve-log-answer-only/check.sh index 7a255d006..8faa28e66 100755 --- a/tests/dns-udp-eve-log-answer-only/check.sh +++ b/tests/dns-udp-eve-log-answer-only/check.sh @@ -1,9 +1,9 @@ #! /bin/sh -. ../../util/functions.sh +. ${TOPDIR}/util/functions.sh # Should be no answers. -n=$(jq_count output/eve.json 'select(.event_type == "dns") | select(.dns.type != "answer")') +n=$(jq_count eve.json 'select(.event_type == "dns") | select(.dns.type != "answer")') assert_eq 0 $n "only answers expected" exit 0 diff --git a/tests/dns-udp-eve-log-mx-only/check.sh b/tests/dns-udp-eve-log-mx-only/check.sh index f6b5a13d7..133517d8d 100755 --- a/tests/dns-udp-eve-log-mx-only/check.sh +++ b/tests/dns-udp-eve-log-mx-only/check.sh @@ -1,8 +1,8 @@ #! /bin/sh -. ../../util/functions.sh +. ${TOPDIR}/util/functions.sh -n=$(jq_count output/eve.json 'select(.dns.rrtype != "MX")') +n=$(jq_count eve.json 'select(.dns.rrtype != "MX")') assert_eq 0 $n "only expected mx records" exit 0 diff --git a/tests/dns-udp-eve-log-query-only/check.sh b/tests/dns-udp-eve-log-query-only/check.sh index 3f8aaad27..284af2161 100755 --- a/tests/dns-udp-eve-log-query-only/check.sh +++ b/tests/dns-udp-eve-log-query-only/check.sh @@ -1,9 +1,9 @@ #! /bin/sh -. ../../util/functions.sh +. ${TOPDIR}/util/functions.sh # Should be no answers. -n=$(jq_count output/eve.json 'select(.event_type == "dns") | select(.dns.type != "query")') +n=$(jq_count eve.json 'select(.event_type == "dns") | select(.dns.type != "query")') assert_eq 0 $n "only queries expected" exit 0 diff --git a/tests/dns-udp-eve-log-txt/check.sh b/tests/dns-udp-eve-log-txt/check.sh index d8a9ef65d..e9ac4b790 100755 --- a/tests/dns-udp-eve-log-txt/check.sh +++ b/tests/dns-udp-eve-log-txt/check.sh @@ -2,7 +2,7 @@ set -e -txt=$(cat output/eve.json | \ +txt=$(cat eve.json | \ jq -c 'select(.dns.type == "answer") | select(.dns.rrtype == "TXT") | .dns.rdata') test "${txt}" = '"v=spf1 include:_spf.google.com ~all"' diff --git a/tests/dns-udp-nxdomain-soa/check.sh b/tests/dns-udp-nxdomain-soa/check.sh index dd64e003d..05a855591 100755 --- a/tests/dns-udp-nxdomain-soa/check.sh +++ b/tests/dns-udp-nxdomain-soa/check.sh @@ -1,9 +1,9 @@ #! /bin/sh -. ../../util/functions.sh +. ${TOPDIR}/util/functions.sh # Look for 2 responses with rcode == "NXDOMAIN". -n=$(jq_count output/eve.json 'select(.dns.rcode == "NXDOMAIN")') +n=$(jq_count eve.json 'select(.dns.rcode == "NXDOMAIN")') assert_eq 2 "$n" "nxdomain responses" exit 0 diff --git a/tests/dns-udp-unsolicited-response/check.sh b/tests/dns-udp-unsolicited-response/check.sh index 02681ab14..f876b16cf 100755 --- a/tests/dns-udp-unsolicited-response/check.sh +++ b/tests/dns-udp-unsolicited-response/check.sh @@ -1,19 +1,19 @@ #! /bin/sh # Check for 1 DNS request. -n=$(cat output/eve.json | jq -c 'select(.dns.type == "query")' | wc -l | xargs) +n=$(cat eve.json | jq -c 'select(.dns.type == "query")' | wc -l | xargs) if [ ${n} -ne 1 ]; then exit 1 fi # Check for 1 DNS response. -n=$(cat output/eve.json | jq -c 'select(.dns.type == "answer")' | wc -l | xargs) +n=$(cat eve.json | jq -c 'select(.dns.type == "answer")' | wc -l | xargs) if [ ${n} -ne 2 ]; then exit 1 fi # Check for one alert. -n=$(cat output/eve.json | jq -c 'select(.event_type == "alert")' | wc -l | xargs) +n=$(cat eve.json | jq -c 'select(.event_type == "alert")' | wc -l | xargs) if [ ${n} -ne 1 ]; then exit 1 fi diff --git a/tests/dns-udp-z-flag-fp/check.sh b/tests/dns-udp-z-flag-fp/check.sh index 6b9072d55..406a19a95 100755 --- a/tests/dns-udp-z-flag-fp/check.sh +++ b/tests/dns-udp-z-flag-fp/check.sh @@ -1,7 +1,7 @@ #! /bin/sh -. ../../util/functions.sh +. ${TOPDIR}/util/functions.sh # Check that there are no events. -n=$(cat output/fast.log | wc -l | xargs) +n=$(cat fast.log | wc -l | xargs) assert_eq 0 "$n" "no events expected" diff --git a/tests/eve-dns/check.sh b/tests/eve-dns/check.sh index 9490460c1..1d8a0ecc4 100755 --- a/tests/eve-dns/check.sh +++ b/tests/eve-dns/check.sh @@ -1,11 +1,11 @@ #! /bin/sh -. ../../util/functions.sh +. ${TOPDIR}/util/functions.sh # 4 queries. -n=$(jq_count output/eve.json 'select(.dns.type == "query")') +n=$(jq_count eve.json 'select(.dns.type == "query")') assert_eq 4 "$n" "queries" # 5 answers. -n=$(jq_count output/eve.json 'select(.dns.type == "answer")') +n=$(jq_count eve.json 'select(.dns.type == "answer")') assert_eq 5 "$n" "answers" diff --git a/tests/filestore-v2.1-forced/test.yaml b/tests/filestore-v2.1-forced/test.yaml index 209498a49..f5bd0fdc9 100644 --- a/tests/filestore-v2.1-forced/test.yaml +++ b/tests/filestore-v2.1-forced/test.yaml @@ -7,7 +7,7 @@ requires: checks: - shell: - args: test -e output/filestore/48/48d179a2f8d17331446c7a75a082851eee9ad841705ed5fbce730f51a0598d62 + args: test -e filestore/48/48d179a2f8d17331446c7a75a082851eee9ad841705ed5fbce730f51a0598d62 - stats: file_store.fs_errors: 0 diff --git a/tests/filestore-v2.2-forced-with-open-files/test.yaml b/tests/filestore-v2.2-forced-with-open-files/test.yaml index 326dfdbb6..a23ff6451 100644 --- a/tests/filestore-v2.2-forced-with-open-files/test.yaml +++ b/tests/filestore-v2.2-forced-with-open-files/test.yaml @@ -9,7 +9,7 @@ pcap: ../filestore-v2.1-forced/suricata-update-pdf.pcap checks: - shell: - args: test -e output/filestore/48/48d179a2f8d17331446c7a75a082851eee9ad841705ed5fbce730f51a0598d62 + args: test -e filestore/48/48d179a2f8d17331446c7a75a082851eee9ad841705ed5fbce730f51a0598d62 - stats: file_store.fs_errors: 0 diff --git a/tests/filestore-v2.3-fserror/test.yaml b/tests/filestore-v2.3-fserror/test.yaml index 6a7648cee..ced5d4266 100644 --- a/tests/filestore-v2.3-fserror/test.yaml +++ b/tests/filestore-v2.3-fserror/test.yaml @@ -13,8 +13,8 @@ pcap: ../filestore-v2.1-forced/suricata-update-pdf.pcap setup: # Create a filestore directory where the rename to will fail. - script: | - mkdir -p output/filestore/48 - chmod 444 output/filestore/48 + mkdir -p filestore/48 + chmod 444 filestore/48 checks: # We should have one file_store.fs_errors. diff --git a/tests/filestore-v2.4-forced-with-meta/test.yaml b/tests/filestore-v2.4-forced-with-meta/test.yaml index b70648937..ee0d746c2 100644 --- a/tests/filestore-v2.4-forced-with-meta/test.yaml +++ b/tests/filestore-v2.4-forced-with-meta/test.yaml @@ -11,10 +11,10 @@ checks: # Check how many lines were logged to fast.log. - shell: - args: cat output/filestore/48/48d179a2f8d17331446c7a75a082851eee9ad841705ed5fbce730f51a0598d62.1515441287.1.json | jq -c 'select(.fileinfo.sha256=="48d179a2f8d17331446c7a75a082851eee9ad841705ed5fbce730f51a0598d62")' | wc -l | xargs + args: cat filestore/48/48d179a2f8d17331446c7a75a082851eee9ad841705ed5fbce730f51a0598d62.1515441287.1.json | jq -c 'select(.fileinfo.sha256=="48d179a2f8d17331446c7a75a082851eee9ad841705ed5fbce730f51a0598d62")' | wc -l | xargs expect: 1 - shell: - args: cat output/filestore/48/48d179a2f8d17331446c7a75a082851eee9ad841705ed5fbce730f51a0598d62.1515441287.1.json | jq -c 'select(.fileinfo.stored==true)' | wc -l | xargs + args: cat filestore/48/48d179a2f8d17331446c7a75a082851eee9ad841705ed5fbce730f51a0598d62.1515441287.1.json | jq -c 'select(.fileinfo.stored==true)' | wc -l | xargs expect: 1 diff --git a/tests/linktype-228/check.sh b/tests/linktype-228/check.sh index 958b2ffcf..a11309df5 100755 --- a/tests/linktype-228/check.sh +++ b/tests/linktype-228/check.sh @@ -1,5 +1,5 @@ #! /bin/sh -tcp=$(cat output/eve.json | \ +tcp=$(cat eve.json | \ jq -c 'select(.event_type == "stats") | .stats.decoder.tcp') test "${tcp}" = "7" diff --git a/tests/lua-output-dns/check.sh b/tests/lua-output-dns/check.sh index 1d4cc6f36..e615993c6 100755 --- a/tests/lua-output-dns/check.sh +++ b/tests/lua-output-dns/check.sh @@ -2,12 +2,12 @@ set -e -if ! grep -q "Query TX 0d4f \[\*\*\] block.dropbox.com \[\*\*\] A \[\*\*\] 10.16.1.11:49697 -> 10.16.1.1:53" output/lua-dns.log; then +if ! grep -q "Query TX 0d4f \[\*\*\] block.dropbox.com \[\*\*\] A \[\*\*\] 10.16.1.11:49697 -> 10.16.1.1:53" lua-dns.log; then echo "failed to find query for block.dropbox.com" exit 1 fi -if ! cat output/lua-dns.log | \ +if ! cat lua-dns.log | \ grep "Response" | \ grep "client-cf.dropbox.com" | \ grep "52.85.112.21" > /dev/null; @@ -16,7 +16,7 @@ then exit 1 fi -if ! cat output/lua-dns.log | \ +if ! cat lua-dns.log | \ grep "Response TX 62b2" | \ grep "NXDOMAIN" > /dev/null; then @@ -24,7 +24,7 @@ then exit 1 fi -if ! cat output/lua-dns.log | grep "SOA" > /dev/null; then +if ! cat lua-dns.log | grep "SOA" > /dev/null; then echo "failed find SOA response record" exit 1 fi diff --git a/tests/lua-output-http/check.sh b/tests/lua-output-http/check.sh index f2a087273..a3f3c1321 100755 --- a/tests/lua-output-http/check.sh +++ b/tests/lua-output-http/check.sh @@ -1,3 +1,3 @@ #! /bin/sh -exec cmp output/http_lua.log expected/http_lua.log +exec cmp http_lua.log ${TEST_DIR}/expected/http_lua.log diff --git a/tests/lua-output-smtp/check.sh b/tests/lua-output-smtp/check.sh index 68a315978..7a3040d02 100755 --- a/tests/lua-output-smtp/check.sh +++ b/tests/lua-output-smtp/check.sh @@ -1,4 +1,4 @@ #! /bin/sh exec grep -q 'FROM TO {}' \ - output/smtp_lua.log + smtp_lua.log diff --git a/tests/output-eve-fileinfo/check.sh b/tests/output-eve-fileinfo/check.sh index 19c998024..4152bddc6 100755 --- a/tests/output-eve-fileinfo/check.sh +++ b/tests/output-eve-fileinfo/check.sh @@ -1,8 +1,8 @@ #! /bin/sh -. ../../util/functions.sh +. ${TOPDIR}/util/functions.sh -filename=$(cat output/eve.json | jq -c .fileinfo.filename) +filename=$(cat eve.json | jq -c .fileinfo.filename) assert_eq '"eicar.com"' "$filename" "bad filename" exit 0 diff --git a/tests/output-pcap-log/check.sh b/tests/output-pcap-log/check.sh index f2253d934..ac1e9efa0 100755 --- a/tests/output-pcap-log/check.sh +++ b/tests/output-pcap-log/check.sh @@ -1,3 +1,3 @@ #! /bin/sh -exec cmp expected/log.pcap.1444144603 output/log.pcap.1444144603 +exec cmp ${TEST_DIR}/expected/log.pcap.1444144603 log.pcap.1444144603 diff --git a/tests/output-tcp-data/check.sh b/tests/output-tcp-data/check.sh index 9430bf368..6a022657a 100755 --- a/tests/output-tcp-data/check.sh +++ b/tests/output-tcp-data/check.sh @@ -1,3 +1,3 @@ #! /bin/sh -exec cmp expected/tcp-data.log output/tcp-data.log +exec cmp ${TEST_DIR}/expected/tcp-data.log tcp-data.log diff --git a/tests/proto-mismatch-http-ssh/check.sh b/tests/proto-mismatch-http-ssh/check.sh index 5f1cc4e91..1a078d7b8 100755 --- a/tests/proto-mismatch-http-ssh/check.sh +++ b/tests/proto-mismatch-http-ssh/check.sh @@ -4,7 +4,7 @@ failed=no # We should get a "SURICATA Applayer Mismatch protocol both # directions" alert. -n=$(cat output/eve.json | \ +n=$(cat eve.json | \ jq -c 'select(.alert.signature_id == 2260000)' | \ wc -l | xargs) if [ "$n" != 1 ]; then @@ -13,7 +13,7 @@ if [ "$n" != 1 ]; then fi # We should have a flow event with app_proto = http and app_proto_tc = ssh. -n=$(cat output/eve.json | \ +n=$(cat eve.json | \ jq -c 'select(.event_type == "flow") | select(.app_proto == "http") | select(.app_proto_tc == "ssh")' | \ wc -l | xargs) if [ "$n" != 1 ]; then diff --git a/tests/single-dns-request/check.sh b/tests/single-dns-request/check.sh index 0481fdbbb..f2d46c6dd 100755 --- a/tests/single-dns-request/check.sh +++ b/tests/single-dns-request/check.sh @@ -1,12 +1,12 @@ #! /bin/sh -. ../../util/functions.sh +. ${TOPDIR}/util/functions.sh # One query for suricon.net. -n=$(jq_count output/eve.json 'select(.dns.type == "query") | select(.dns.rrname == "suricon.net")') +n=$(jq_count eve.json 'select(.dns.type == "query") | select(.dns.rrname == "suricon.net")') assert_eq 1 "$n" "request" # One answer with rdata of 181.224.138.142. -n=$(jq_count output/eve.json 'select(.dns.type == "answer") | select(.dns.rdata == "181.224.138.142")') +n=$(jq_count eve.json 'select(.dns.type == "answer") | select(.dns.rdata == "181.224.138.142")') assert_eq 1 "$n" "response" diff --git a/tests/tls-fingerprint-alert/check.sh b/tests/tls-fingerprint-alert/check.sh index 0ba206050..f43b9a295 100755 --- a/tests/tls-fingerprint-alert/check.sh +++ b/tests/tls-fingerprint-alert/check.sh @@ -1,7 +1,7 @@ #! /usr/bin/env bash # Check for a single alert. -n=$(cat output/eve.json | jq -c 'select(.event_type == "alert")' | wc -l | xargs) +n=$(cat eve.json | jq -c 'select(.event_type == "alert")' | wc -l | xargs) if test "${n}" -ne 1; then echo "expected 1 event, found ${n}" exit 1 diff --git a/tests/tls-json-output-ids/check.sh b/tests/tls-json-output-ids/check.sh index 43fd6955f..b7342ce7f 100755 --- a/tests/tls-json-output-ids/check.sh +++ b/tests/tls-json-output-ids/check.sh @@ -1,7 +1,7 @@ #! /usr/bin/env bash # Check for 1 tls event. -n=$(cat output/eve.json | jq -c 'select(.event_type == "tls")' | wc -l | xargs) +n=$(cat eve.json | jq -c 'select(.event_type == "tls")' | wc -l | xargs) if test "${n}" -ne 1; then echo "expected 1 event, got $n" exit 1 diff --git a/tests/tls-json-output-ips/check.sh b/tests/tls-json-output-ips/check.sh index 43fd6955f..b7342ce7f 100755 --- a/tests/tls-json-output-ips/check.sh +++ b/tests/tls-json-output-ips/check.sh @@ -1,7 +1,7 @@ #! /usr/bin/env bash # Check for 1 tls event. -n=$(cat output/eve.json | jq -c 'select(.event_type == "tls")' | wc -l | xargs) +n=$(cat eve.json | jq -c 'select(.event_type == "tls")' | wc -l | xargs) if test "${n}" -ne 1; then echo "expected 1 event, got $n" exit 1