summaryrefslogtreecommitdiff
path: root/ext/websocket/autobahn/fuzzingclient.js
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2023-05-01 18:07:32 +0530
committerGitHub <noreply@github.com>2023-05-01 14:37:32 +0200
commit89160e7cd8647fdf2ebaec45259775be89aa69c7 (patch)
treea9b5df0d14ee59b6de7105d72557d4643bad41e9 /ext/websocket/autobahn/fuzzingclient.js
parentb31cf9fde6ad5398c20370c136695db77df6beeb (diff)
chore(ext/websocket): readd autobahn|testsuite fuzzingclient (#18903)
This reverts commit https://github.com/denoland/deno/commit/17d1c7e444542f43229a047853605ac22081abdf. The `Deno.serve` signature update in https://github.com/denoland/deno/pull/18759 broke the testee server right after this patch landed on `main`.
Diffstat (limited to 'ext/websocket/autobahn/fuzzingclient.js')
-rw-r--r--ext/websocket/autobahn/fuzzingclient.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/ext/websocket/autobahn/fuzzingclient.js b/ext/websocket/autobahn/fuzzingclient.js
new file mode 100644
index 000000000..8aa716695
--- /dev/null
+++ b/ext/websocket/autobahn/fuzzingclient.js
@@ -0,0 +1,33 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+
+// deno-lint-ignore-file
+
+import { $ } from "https://deno.land/x/dax@0.31.0/mod.ts";
+
+const pwd = new URL(".", import.meta.url).pathname;
+
+const AUTOBAHN_TESTSUITE_DOCKER =
+ "crossbario/autobahn-testsuite:0.8.2@sha256:5d4ba3aa7d6ab2fdbf6606f3f4ecbe4b66f205ce1cbc176d6cdf650157e52242";
+
+const self = Deno.execPath();
+$`${self} run -A --unstable ${pwd}/autobahn_server.js`.spawn();
+await $`docker run --name fuzzingserver -v ${pwd}/fuzzingclient.json:/fuzzingclient.json:ro -v ${pwd}/reports:/reports -p 9001:9001 --net=host --rm ${AUTOBAHN_TESTSUITE_DOCKER} wstest -m fuzzingclient -s fuzzingclient.json`
+ .cwd(pwd);
+
+const { deno_websocket } = JSON.parse(
+ Deno.readTextFileSync(`${pwd}/reports/servers/index.json`),
+);
+const result = Object.values(deno_websocket);
+
+function failed(name) {
+ return name != "OK" && name != "INFORMATIONAL" && name != "NON-STRICT";
+}
+
+const failedtests = result.filter((outcome) => failed(outcome.behavior));
+
+console.log(
+ `%c${result.length - failedtests.length} / ${result.length} tests OK`,
+ `color: ${failedtests.length == 0 ? "green" : "red"}`,
+);
+
+Deno.exit(failedtests.length == 0 ? 0 : 1);