chiark / gitweb /
log capturing
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 22 Aug 2021 21:48:09 +0000 (22:48 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 22 Aug 2021 21:48:09 +0000 (22:48 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Makefile
test/capture-log [new file with mode: 0755]
test/t-basic

index 0cf5f10c5dedea6ccd3ced1826c5c326e45da7e4..7a4a7b204d655594538dfee68e4cd753d552fcff 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -11,8 +11,6 @@ TARGET_DIR    ?= target
 
 SPHINXBUILD    ?= sphinx-build
 
-CFLAGS         += -Wall
-
 ifneq (,$(wildcard ../Cargo.nail))
 
 NAILING_CARGO ?= nailing-cargo
@@ -29,16 +27,25 @@ rsrcs = $(shell $(foreach x,$(MAKEFILE_FIND_X),set -$x;)\
     find -H $1 \( -name Cargo.toml -o -name Cargo.lock -o -name Cargo.lock.example -o -name \*.rs \) )
 stamp=@mkdir -p stamp; touch $@
 
+TESTS=$(notdir $(wildcard test/t-*[^~]))
+
 all:   cargo-build doc
 
-check: all rndaddtoentcnt-build
+check: cargo-test $(addprefix stamp/,$(TESTS))
 
 cargo-build: stamp/cargo-build
+cargo-test: # stamp/cargo-test xxx
 
-stamp/cargo-build: $(call rsrcs,.)
-       $(NAILING_CARGO) build $(CARGO_BUILD_OPTIONS)
+stamp/cargo-%: $(call rsrcs,.)
+       $(NAILING_CARGO) $* $(CARGO_BUILD_OPTIONS)
        $(stamp)
 
+stamp/t-%: test/t-% stamp/cargo-build $(wildcard test/*[^~])
+       $(NAILING_CARGO_JUST_RUN) \
+       $(abspath test/capture-log) tmp/t-$*.log \
+       $(abspath test/go-with-unshare test/t-$*)
+       @echo OK t-$*; touch $@
+
 doc:   docs/html/index.html
        @echo 'Documentation can now be found here:'
        @echo '  file://$(PWD)/$<'
@@ -46,10 +53,8 @@ doc: docs/html/index.html
 docs/html/index.html: docs/conf.py $(wildcard docs/*.md docs/*.rst docs/*.png)
        $(SPHINXBUILD) -M html docs docs $(SPHINXOPTS)
 
-rndaddtoentcnt-build: uml/rndaddtoentcnt/rndaddtoentcnt
-
 clean:
        rm -rf stamp/* doc/html
        $(NAILING_CARGO) clean
 
-.PHONY: cargo-build rndaddtoentcnt-build all doc clean
+.PHONY: cargo-build all doc clean
diff --git a/test/capture-log b/test/capture-log
new file mode 100755 (executable)
index 0000000..ff13c6b
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/bash
+# Copyright 2020-2021 Ian Jackson and contributors to Otter
+# SPDX-License-Identifier: GPL-3.0-or-later
+# There is NO WARRANTY.
+set -e
+
+log="$1"; shift
+mkdir -p tmp
+"$@" 2>&1 | ts >"$log"
index b1c145e4072c0c629b8f07553276c2ce8b0ce985..039a3cdf84489dd5665cdd508d0a53404f588b83 100755 (executable)
@@ -10,5 +10,5 @@ test-prep
 start-server
 start-client
 
-in-ns client ping -c 10 192.0.2.1 >$tmp/ping
+in-ns client ping -i 0.1 -c 10 192.0.2.1 >$tmp/ping
 grep ' 0% packet loss' $tmp/ping