Skip to content

Commit

Permalink
Merge pull request #368 from Jafaral/test-posix
Browse files Browse the repository at this point in the history
tests: fix a few posix issues. Skip test if feature isn't supported
  • Loading branch information
Don-Ward authored Mar 4, 2024
2 parents 3cb632f + d8e9e9b commit 4348a58
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 41 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ uni/udb/udb
uni/udb/udap/udap
uni/udb/udap/dapcom
uni/unicon/unicon
uni/unicon/nocc.icn
uni/unicon/nocchelper
uni/unidep/unidep
uni/unidoc/.lastbuild
uni/unidoc/unidoc
Expand Down
16 changes: 12 additions & 4 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"options": {
"cwd": "${workspaceFolder}"
},
"args": [ "-j" ],
"args": [
"-j"
],
"group": {
"kind": "build",
"isDefault": true
Expand All @@ -20,7 +22,10 @@
"options": {
"cwd": "${workspaceFolder}/src/runtime"
},
"args": [ "-j", "iconx" ],
"args": [
"-j",
"iconx"
],
"group": {
"kind": "build",
"isDefault": true
Expand All @@ -33,7 +38,9 @@
"options": {
"cwd": "${workspaceFolder}/src"
},
"args": [ "-j" ],
"args": [
"-j"
],
"group": {
"kind": "build",
"isDefault": true
Expand Down Expand Up @@ -81,7 +88,8 @@
"command": "configure",
"args": [
"--enable-debug",
"--enable-devmode"
"--enable-devmode",
"--disable-iconc"
],
"group": {
"kind": "build",
Expand Down
5 changes: 4 additions & 1 deletion tests/Makefile.test
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ $(IGNORE):
else ./$@ > local/[email protected] 2>&1; fi || true
-@echo "Expect/ignore these differences in $@:"
-@diff stand/[email protected] local/[email protected]; \
@if [ $$? -eq 0 ] ; then echo "OK"; \
if [ $$? -eq 0 ] ; then echo "OK"; \
else echo "[Test $@] Ignored"; fi || true
-@rm $@$(EXE)

Expand Down Expand Up @@ -63,8 +63,11 @@ endif
diff --suppress-common-lines -wy stand/[email protected] local/[email protected] > [email protected]; fi \
else diff -wq stand/[email protected] local/[email protected] >/dev/null; \
if [ $$? -eq 0 ] ; then echo "OK"; \
else \
if grep -qi "This Program Requires" local/[email protected]; then cat local/[email protected]; \
else echo "Failed"; \
diff --suppress-common-lines -wy stand/[email protected] local/[email protected] > [email protected]; fi \
fi; \
fi || true
-@rm $@$(EXE)

Expand Down
10 changes: 6 additions & 4 deletions tests/general/ssl.icn
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ class Server(addrport, mode, opt, rounds)
rounds := 4
opt := [addrport, "nae", key, cert, ca]
}
"TLS1.1 Min": {
"TLS1.2 Min": {
rounds := 3;
opt := [addrport, "nae", key, cert, ca, "minProto=TLS1.1"]
opt := [addrport, "nae", key, cert, ca, "minProto=TLS1.2"]
}

"Client Auth": {
Expand Down Expand Up @@ -187,6 +187,8 @@ procedure main(args)

if not (&features == "secure sockets layer encryption") then
stop("This program requires secure sockets layer encryption.")
if not (&features == "concurrent threads") then
stop("This program requires concurrent threads.")

interactive := args[1]

Expand All @@ -196,8 +198,8 @@ procedure main(args)
ssltest("Encrypted sockets", "TLS",
[["No TLS", "Fail"], ["TLS No CA", "Fail"], ["TLS No Verify", "Pass"], ["TLS With CA", "Pass"]])

ssltest("TLS versions", "TLS1.1 Min",
[["TLS1.0", "Fail"], ["TLS1.1", "Pass"], ["TLS1.2", "Pass"]])
ssltest("TLS versions", "TLS1.2 Min",
[["TLS1.0", "Fail"], ["TLS1.1", "Fail"], ["TLS1.2", "Pass"]])

ssltest("Client authentication", "Client Auth",
[["TLS No Cert", "Fail"], ["Client Auth", "Pass"]])
Expand Down
9 changes: 4 additions & 5 deletions tests/posix/getserv.icn
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ $include "posix.icn"

procedure main()

s := getserv("daytime") | stop("Couldn't get service \"daytime\"")
s := getserv("ntp") | stop("Couldn't get service \"daytime\"")
sdump(s)
port := 22
port := s.port
s := getserv(port) | stop("Couldn't get service for port ", port)
sdump(s)

end

procedure sdump(s)
writes(s.name, "\t\t", s.port, "/", s.proto)
writes("\t\t#", s.aliases)
write()
writes(left(s.name, 10), left(s.port || "/" || s.proto, 10))
write("[", s.aliases, "]")
end
4 changes: 2 additions & 2 deletions tests/posix/stand/getserv.std
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
daytime 13/tcp #
ssh 22/tcp #
ntp 123/udp []
ntp 123/udp []
9 changes: 6 additions & 3 deletions tests/posix/udp.icn
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
$include "posix.icn"

procedure main()

port:=":1072"
if fork() == 0 then {
f := open(":1072", "nua")
f := open(port, "nua")

if r := receive(f) then {
# Process the request in r.msg - in the case of the time
Expand All @@ -14,7 +14,10 @@ procedure main()
}

delay(100)
f := open(":1072", "nu") |
if (&features == "MacOS") then
port := "localhost" || port

f := open(port, "nu") |
stop("Open failed: ", sys_errstr(&errno))

write(f, "")
Expand Down
21 changes: 12 additions & 9 deletions tests/posix/uxsocket.icn
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
$include "posix.icn"

procedure main()

sock := "revsock" || (?900 + 100)
if fork() ~== 0 then {
# parent
delay(1000)
f := open("revsock", "n") | stop("Couldn't connect: ",
sys_errstr(&errno))
f := open(sock, "n") |
stop("Couldn't connect: ", sys_errstr(&errno))

write(f, "hello, world!")
write(read(f))
Expand All @@ -18,15 +18,18 @@ procedure main()
}

# child
if f := open("revsock", "na") then {
if f := open(sock, "na") then {
if fork() = 0 then {
handle(f)
close(f)
exit(0)
handle(f)
close(f)
exit(0)
}
close(f)

system("rm revsock")
if (&features == "MacOS") then
# workaround a bug on MacOS where the name is one character shorter
system("rm " || sock[1:-1])
else
system("rm " || sock)
}
(&errno = 0) | stop("Couldn't accept: ", sys_errstr(&errno))
end
Expand Down
2 changes: 1 addition & 1 deletion tests/thread/sharelist.icn
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
global L, m
procedure main()
if not (&features == "concurrent threads") then
stop("requires concurrent threads")
stop("This program requires concurrent threads.")
n := 4
L := mutex( [ ] )
m := 100000
Expand Down
4 changes: 4 additions & 0 deletions tests/thread/sum.icn
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
global gsum, usermode
procedure main(argv)

if not (&features == "concurrent threads") then
stop("This program requires concurrent threads.")

gsum:=0
thrd := []

Expand Down
2 changes: 1 addition & 1 deletion tests/unicon/FxPtTest.icn
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

procedure main(args)
if not(&features == "large integers") then
stop("large integers not supported")
stop("This program requires large integers.")

runTests(args)
end
Expand Down
8 changes: 4 additions & 4 deletions tests/unicon/FxPtTest_OVLD.icn
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
# --------------------------------------------------------------------------------

procedure main(args)
if not(&features == "large integers") then
stop("large integers not supported")

if not (&features == "operator overloading") then
stop("operator overloading not supported")
stop("This program requires operator overloading.")

if not(&features == "large integers") then
stop("This program requires large integers.")

runTests(args)
end
Expand Down
7 changes: 0 additions & 7 deletions tests/unicon/Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@

include ../Makedefs

ifneq ("$(wildcard $(UC))","")
TARGETS=$(patsubst %.icn,%,$(wildcard *.icn))

SKIP= tester FxPtTests\
audio dbi list_test nlm q rec test testnlm clin_err hello mintest ovld q2 sel to
else
skip:
@echo "Unicon compiler not found"

TARGETS=skip
endif

Test: DoTest

Expand Down

0 comments on commit 4348a58

Please sign in to comment.