From 886ce1f261d038a7a7f22b1a810b584c61f25b3b Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Sun, 6 Jun 2021 01:46:03 +0200 Subject: [PATCH] Switch 'make check' to be done via shelltestrunner The embedding of tests in the Makefile works only for that is there today - a few `--version` and `stinit -p` calls. For expanding the test coverage, as much as it can be done for `mt`, let's use a proper shell test runner. `shelltestrunner` is available in Debian/Ubuntu, so it's likely to be available in other distributions too, and as such should not be a big barrier to contribution. --- .github/workflows/ci.yml | 3 +++ Makefile | 8 +------- tests/basic.test | 21 +++++++++++++++++++++ tests/stinit-parsing.test | 9 +++++++++ 4 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 tests/basic.test create mode 100644 tests/stinit-parsing.test diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 28ac89e..0fd4bd3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,6 +46,9 @@ jobs: - name: Checkout uses: actions/checkout@v2 + - name: Install dependencies + run: sudo apt-get install -yy shelltestrunner + - name: Build the code run: make CFLAGS=-coverage diff --git a/Makefile b/Makefile index 1610053..3b204a1 100644 --- a/Makefile +++ b/Makefile @@ -87,13 +87,7 @@ distcheck: dist test "$$numfiles" -eq 5 check: $(PROGS) - echo Checking version output - ./mt --version - ./stinit --version - echo Checking parse status - ./stinit -p -f stinit.def.examples - echo Checking complete stinit parsing - ( ./stinit -v -v -p -f stinit.def.examples 2>&1 | grep -q 'Mode 1 definition: scsi2logical=1 can-bsr=1 auto-lock=0 two-fms=0 drive-buffering=1 buffer-writes read-ahead=1 async-writes=1 can-partitions=0 fast-eom=1 blocksize=0 sili=1 timeout=900 long-timeout=14400 density=0x44 compression=0' ) + shelltest -DVERSION=$(VERSION) tests # This needs lcov installed, and it's useful for local testing. coverage: clean diff --git a/tests/basic.test b/tests/basic.test new file mode 100644 index 0000000..9aa8b8a --- /dev/null +++ b/tests/basic.test @@ -0,0 +1,21 @@ +# Check --version works +./mt --version +>>> /VERSION/ +>>>= 0 + +./mt -v +>>> /VERSION/ +>>>= 0 + +./stinit --version +>>> /VERSION/ +>>>= 0 + +# Check -h works +./mt -h +>>>2 /commands: weof, wset, eof/ +>>>= 0 + +./stinit -h +>>>2 /Usage: stinit/ +>>>= 0 diff --git a/tests/stinit-parsing.test b/tests/stinit-parsing.test new file mode 100644 index 0000000..9827880 --- /dev/null +++ b/tests/stinit-parsing.test @@ -0,0 +1,9 @@ +# Check example file parsing +./stinit -p -f stinit.def.examples +>>>= 0 + +# Checking complete stinit parsing +./stinit -v -v -p -f stinit.def.examples +>>> /No errors found./ +>>>2 /Mode 1 definition: scsi2logical=1 can-bsr=1 auto-lock=0 two-fms=0 drive-buffering=1 buffer-writes read-ahead=1 async-writes=1 can-partitions=0 fast-eom=1 blocksize=0 sili=1 timeout=900 long-timeout=14400 density=0x44 compression=0/ +>>>= 0