#!/bin/sh # brintOS wasm32-hwjs: meta-networking's run-ptest with upstream's OWN two tests # added ahead of its two demo programs. # # meta-networking ships only `benchmark` and `test-geoip-city`. Neither asserts # anything: benchmark prints lookup rates and returns 0 whatever it measured # (a missing database is a printf, not a failure), and test-geoip-city prints # one tab-separated row per address in city_test.txt and returns 0 unconditionally. # So as packaged this ptest passes unless a program crashes -- it cannot detect a # geolocation answered WRONGLY, which is the only interesting way this library # fails. # # test-geoip and test-geoip-invalid-file are the two programs upstream actually # lists in TESTS, and between them they make ~616 assertions -- every address in # country_test.txt checked four ways (code/code3 x by-addr/by-name) against its # expected country, over both the filesystem and memory-cache open modes, plus # the database-info string, the NULL-query contract and the invalid-database # contract. The bbappend installs them and their fixtures; this file runs them. # # They go FIRST so a real regression is the first line of the report rather than # the last. # # `[ $? = 0 ]`, not upstream's `[ $? == 0 ]`. `==` is a bash extension to test(1); # busybox ash accepts it, which is why it has survived on the images this ptest # has run on, but dash does not, and there it is not a wrong verdict on one case # but on all of them: measured natively, upstream's script under /bin/sh -> dash # emits `[: 0: unexpected operator` and reports FAIL for all four programs while # every one of them exited 0. pdir=`dirname $0` cd ${pdir}/tests for i in ./test-geoip ./test-geoip-invalid-file ./benchmark ./test-geoip-city ; do ${i} 1>/dev/null 2>&1; if [ $? = 0 ]; then echo PASS: $i; else echo FAIL: $i; fi; done