Compare commits

...

4 Commits

Author SHA1 Message Date
DTB
e7021e127c
Testfile: make non-executable 2024-03-13 18:20:30 -06:00
DTB
417d7ca405
Testfile: fix syntax 2024-03-11 21:03:53 -06:00
DTB
f7a74dc430
Testfile 2024-03-11 21:01:29 -06:00
DTB
cabe08bca4
TESTING: start testing document/script 2024-02-29 20:33:09 -07:00
2 changed files with 80 additions and 0 deletions

View File

@ -14,6 +14,7 @@
PREFIX=/usr/local
CC=cc
MAKE=make
RUSTC=rustc
.PHONY: all
@ -42,6 +43,7 @@ install: dist
test: build
tests/posix-compat.sh
$(RUSTC) --test src/getopt-rs/lib.rs -o build/test/getopt
$(MAKE) -f Testfile
build/o/libsysexits.rlib: build
# bandage solution until bindgen(1) gets stdin support

78
Testfile Normal file
View File

@ -0,0 +1,78 @@
#!/usr/bin/env make
# Copyright (c) 2024 DTB <trinity@trinity.moe>
# SPDX-License-Identifier: FSFAP
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and this
# notice are preserved. This file is offered as-is, without any warranty.
BIN = build/bin
MAKE = make -B
DEFENDANTS = dj false intcmp strcmp true
.PHONY: all $(DEFENDANTS)
all: $(DEFENDANTS)
$(BIN)/dj:
$(MAKE) dj
$(BIN)/false:
$(MAKE) false
$(BIN)/intcmp:
$(MAKE) intcmp
$(BIN)/strcmp:
$(MAKE) strcmp
$(BIN)/true:
$(MAKE) true
dj: $(BIN)/dj $(BIN)/strcmp
sh -c "! $(BIN)/dj -h"
# This test is theoretically Linux-dependent; write(2) should return -1 on
# error.
# Right now dj(1) interprets the return value of write(2) as the amount of
# bytes written. This can decrement the stored quantity of bytes written,
# which is an int, so doesn't underflow but goes negative. dj(1) tries to
# again to write(2) if an error occurs in which no bytes are written, so in
# total two write(2)s are attempted and so the written byte quantity is -2.
# This is a bug and will change, but for now is at least documented.
sh -ec "\
$(BIN)/dj -Hi /dev/zero -o /dev/full \
| xargs -I out $(BIN)/strcmp '1+0 > 0+0; 1024 > -2' out"
# Read nothing from /dev/null, write nothing to /dev/null.
sh -ec "\
$(BIN)/dj -Hi /dev/null -o /dev/null \
| xargs -I out $(BIN)/strcmp '0+0 > 0+0; 0 > 0' out"
false: $(BIN)/false
sh -c "! $(BIN)/false"
sh -c "! $(BIN)/false -h"
intcmp: $(BIN)/intcmp
$(BIN)/intcmp -e 3 3 3
$(BIN)/intcmp -g 3 2 1
$(BIN)/intcmp -l 1 2 3
$(BIN)/intcmp -ge 3 3 1
$(BIN)/intcmp -le 1 3 3
$(BIN)/intcmp -gl 1 2 3
$(BIN)/intcmp -egl 3 1 1 2
sh -c "! $(BIN)/intcmp -e 1 2 3"
sh -c "! $(BIN)/intcmp -g 1 3 3"
sh -c "! $(BIN)/intcmp -l 3 3 1"
sh -c "! $(BIN)/intcmp -ge 1 2 3"
sh -c "! $(BIN)/intcmp -le 3 2 1"
sh -c "! $(BIN)/intcmp -gl 3 3 3"
sh -c "! $(BIN)/intcmp -egl foo"
strcmp: $(BIN)/strcmp
$(BIN)/strcmp equals equals
sh -c "! $(BIN)/strcmp inequals equals"
$(BIN)/strcmp - -
sh -c "! $(BIN)/strcmp -h"
sh -c "! $(BIN)/strcmp nocmp"
true:
$(BIN)/true
$(BIN)/true -h