Files
mdg-filius/tools/java-oracle/run.sh
T
julian.kiedaischandClaude Opus 5.5 27ab7a1f49 feat(doc): F4.4a devices and cables in the document, undo per person; NewDeviceRun
A new device is what Java's palette makes, measured with the new oracle
NewDeviceRun (every kind and router size saved as FILIUS saves). Devices
move to whole pixels and go with their cables; a cable takes the first free
port, a home router's WAN port unless its LAN port is asked for, a wireless
host only joins a switch, two devices join once, each refusal named with
Java's message. Each person's undo takes back their own changes only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 09:18:14 +00:00

345 lines
20 KiB
Bash
Executable File

#!/bin/sh
# Reads every .fls under corpus/ with Java FILIUS itself and writes
# corpus/corpus.java.json. Java is the arbiter for the file format (plan §13, M2).
# Needs a JDK (17+), Maven and xvfb-run: FILIUS opens its main window while
# loading (Information.reset → JMainFrame), so it needs a display, not headless.
set -eu
here="$(cd "$(dirname "$0")" && pwd)"
root="$(cd "$here/../.." && pwd)"
commit=6640354
upstream="$here/.upstream"
if [ ! -d "$upstream/.git" ]; then
git clone -q https://gitlab.com/filius1/filius.git "$upstream"
fi
if [ "$(git -C "$upstream" rev-parse --short=7 HEAD)" != "$commit" ]; then
git -C "$upstream" fetch -q origin
git -C "$upstream" checkout -q "$commit"
rm -rf "$upstream/target"
fi
if [ ! -f "$upstream/target/filius.jar" ]; then
(cd "$upstream" && mvn -q -DskipTests package dependency:copy-dependencies -DoutputDirectory=target/lib)
fi
classpath="$upstream/target/filius.jar:$upstream/target/lib/*"
mkdir -p "$here/.build"
javac -encoding UTF-8 -d "$here/.build" -cp "$classpath" "$here/src/FlsOracle.java" "$here/src/GetterDefaults.java" "$here/src/IpCheckCases.java" "$here/src/DnsHostsCases.java" "$here/src/EmailFileCases.java" "$here/src/BeansDump.java" "$here/src/Base64Cases.java" "$here/src/ScenarioNetwork.java" "$here/src/DhcpRun.java" "$here/src/TcpRun.java" "$here/src/DnsRun.java" "$here/src/ArpRun.java" "$here/src/RipRun.java" "$here/src/NatRun.java" "$here/src/WlanRun.java" "$here/src/ExampleRun.java" "$here/src/EchoRun.java" "$here/src/WebRun.java" "$here/src/RouterWebRun.java" "$here/src/KonfigCases.java" "$here/src/EmailRun.java" "$here/src/MailCases.java" "$here/src/EmailClientRun.java" "$here/src/TerminalCases.java" "$here/src/TerminalRun.java" "$here/src/FileCases.java" "$here/src/GnutellaRun.java" "$here/src/NewDeviceRun.java"
# FILIUS writes its settings below $HOME; keep them out of the real one.
mkdir -p "$here/.build/home"
# Removed first: a crashed run must not leave the previous result standing.
rm -f "$root/corpus/corpus.java.json"
HOME="$here/.build/home" xvfb-run -a java -cp "$classpath:$here/.build" FlsOracle \
"$root/corpus" "$root/corpus/corpus.java.json" 2>&1 | grep -v 'logback\|^$' || true
test -s "$root/corpus/corpus.java.json"
# Getter defaults and static constants for the XMLEncoder references (packages/fls/src/javaDefaults.json).
defaults="$root/packages/fls/src/javaDefaults.json"
rm -f "$defaults"
HOME="$here/.build/home" xvfb-run -a java -cp "$classpath:$here/.build" GetterDefaults "$defaults" \
filius.gui.netzwerksicht.JSidebarButton#iconTextGap \
filius.gui.netzwerksicht.JSidebarButton#verticalTextPosition \
filius.gui.netzwerksicht.JSidebarButton#displayedMnemonicIndex \
filius.gui.netzwerksicht.JSidebarButton#debugGraphicsOptions \
filius.gui.netzwerksicht.JSidebarButton#enabled \
java.lang.ThreadGroup#maxPriority \
filius.hardware.knoten.Rechner#maxLayerOfOperation \
filius.hardware.knoten.Notebook#maxLayerOfOperation \
filius.hardware.knoten.Vermittlungsrechner#maxLayerOfOperation \
filius.hardware.knoten.Gateway#maxLayerOfOperation \
filius.software.clientserver.ServerBaustein#port \
filius.software.dhcp.DHCPServer#port \
filius.software.dns.DNSServer#port \
filius.software.rip.RIPServer#port \
filius.software.www.WebServer#port \
javax.swing.SwingConstants::CENTER \
filius.software.clientserver.ServerBaustein#aktiv \
filius.software.clientserver.ClientBaustein#zielPort \
filius.software.clientserver.ClientBaustein#zielIPAdresse \
filius.software.dns.DNSServer#aktiv \
filius.software.www.WebServer#aktiv \
filius.software.www.WebServer#useVHost \
filius.software.dateiaustausch.PeerToPeerAnwendung#maxTeilnehmerZahl \
2>&1 | grep -v 'logback\|^$' || true
test -s "$defaults"
# IP.ipCheck on hand-picked cases (packages/fls/src/javaIp.ts).
cases="$root/packages/fls/test/ip-check.cases.txt"
ipcheck="$root/packages/fls/test/ip-check.java.json"
rm -f "$ipcheck"
HOME="$here/.build/home" java -cp "$classpath:$here/.build" IpCheckCases "$cases" "$ipcheck" 2>&1 | grep -v 'logback\|^$' || true
test -s "$ipcheck"
# Base64.encodeBytes around its line length (packages/fls/src/exportProject.ts, javaBase64).
base64="$root/packages/fls/test/base64.java.json"
rm -f "$base64"
HOME="$here/.build/home" java -cp "$classpath:$here/.build" Base64Cases "$base64" 0 1 2 3 55 56 57 58 59 113 114 115 116 171 172 2000 2001 2002 2052 2>&1 | grep -v 'logback\|^$' || true
test -s "$base64"
# DNSServer's own reading of /dns/hosts on hand-picked files (packages/fls/src/dnsHosts.ts).
cases="$root/packages/fls/test/dns-hosts.cases.txt"
dnshosts="$root/packages/fls/test/dns-hosts.java.json"
rm -f "$dnshosts"
HOME="$here/.build/home" xvfb-run -a java -cp "$classpath:$here/.build" DnsHostsCases "$cases" "$dnshosts" 2>&1 | grep -v 'logback\|^$' || true
test -s "$dnshosts"
# EmailServer.kontenLaden and EmailAnwendung.laden on hand-picked account files (packages/fls/src/javaEmail.ts).
for kind in server client; do
cases="$root/packages/fls/test/email-$kind.cases.txt"
output="$root/packages/fls/test/email-$kind.java.json"
rm -f "$output"
HOME="$here/.build/home" xvfb-run -a java -cp "$classpath:$here/.build" EmailFileCases "$kind" "$cases" "$output" 2>&1 | grep -v 'logback\|^$' || true
test -s "$output"
done
# What XMLDecoder makes of the files packages/fls/src/javaBeansWriter.ts writes.
beans="$root/packages/fls/test/beans"
rm -f "$beans/beans.java.json"
HOME="$here/.build/home" xvfb-run -a java -cp "$classpath:$here/.build" BeansDump "$beans" "$beans/beans.java.json" 2>&1 | grep -v 'logback\|^$' || true
test -s "$beans/beans.java.json"
# What Java loads from the files packages/fls writes: Java's view written
# again (topologyWriter.test.ts, UPDATE_WRITTEN=1) and the editor model
# exported (exportProject.test.ts, UPDATE_EXPORTED=1). The files are not
# checked in, their SHA-256 is.
for written in "$root/packages/fls/test/written" "$root/packages/fls/test/exported"; do
if [ -d "$written" ]; then
rm -f "$written.java.json"
HOME="$here/.build/home" xvfb-run -a java -cp "$classpath:$here/.build" FlsOracle "$written" "$written.java.json" --sha256 2>&1 | grep -v 'logback\|^$' || true
test -s "$written.java.json"
fi
done
# DHCP as Java FILIUS runs it: a core scenario's network, started as the
# action mode starts it, for the given real-time milliseconds; every frame
# each card saw and the addresses at the end (packages/core/test/dhcpJava.test.ts).
# One run after another: a busy machine stretches the times.
for run in dhcp-lan:8000 dhcp-two-servers:8000 dhcp-conflict:25000 dhcp-no-server:25000; do
name="${run%%:*}"
output="$root/packages/core/test/scenarios/$name.java.json"
rm -f "$output"
HOME="$here/.build/home" xvfb-run -a java -cp "$classpath:$here/.build" DhcpRun \
"$root/packages/core/test/scenarios/$name.scenario.json" "${run##*:}" "$output" 2>&1 | grep -v 'logback\|^$' || true
test -s "$output"
done
# TCP as Java FILIUS runs it: stories of socket calls on tcp-lan's network
# (TcpRun); frames, calls and socket states, for the core's TCP comparison.
for run in exchange:30000 closedPort:30000 lostData:45000 lostSynAck:70000 lostFin:60000 lostLastFin:60000; do
story="${run%%:*}"
output="$root/packages/core/test/scenarios/tcp-java-$story.java.json"
rm -f "$output"
HOME="$here/.build/home" xvfb-run -a java -cp "$classpath:$here/.build" TcpRun \
"$root/packages/core/test/scenarios/tcp-lan.scenario.json" "$story" "${run##*:}" "$output" 2>&1 | grep -v 'logback\|^$' || true
test -s "$output"
done
# DNS as Java FILIUS runs it: a resolver's lookup on dns-lan's network
# (DnsRun); frames and the call's result, for the core's DNS comparison.
for run in address:5000 mail:5000 referral:5000 unknown:5000 noServer:22000; do
story="${run%%:*}"
output="$root/packages/core/test/scenarios/dns-java-$story.java.json"
rm -f "$output"
HOME="$here/.build/home" xvfb-run -a java -cp "$classpath:$here/.build" DnsRun \
"$root/packages/core/test/scenarios/dns-lan.scenario.json" "$story" "${run##*:}" "$output" 2>&1 | grep -v 'logback\|^$' || true
test -s "$output"
done
# The same with a recursive server (dns-recursive). unknownInOwnZone asks
# itself without end: a short run, and a bounded heap.
for run in address:5000 referral:5000 unknown:5000 unknownInZone:5000 unknownInOwnZone:15500; do
story="${run%%:*}"
output="$root/packages/core/test/scenarios/dns-recursive-java-$story.java.json"
rm -f "$output"
HOME="$here/.build/home" xvfb-run -a java -Xmx1g -cp "$classpath:$here/.build" DnsRun \
"$root/packages/core/test/scenarios/dns-recursive.scenario.json" "$story" "${run##*:}" "$output" 2>&1 | grep -v 'logback\|^$' || true
test -s "$output"
done
# NAT as Java FILIUS runs it: nat-home's home router between a LAN PC and two
# WAN hosts (NatRun); frames, calls and the router's NAT table at the end.
for run in pingOut:10000 udpOut:10000 udpTwoRemotes:25000 tcpOut:20000 forward:20000 pingWan:15000 ttlOut:10000; do
story="${run%%:*}"
output="$root/packages/core/test/scenarios/nat-java-$story.java.json"
rm -f "$output"
HOME="$here/.build/home" xvfb-run -a java -cp "$classpath:$here/.build" NatRun \
"$root/packages/core/test/scenarios/nat-home.scenario.json" "$story" "${run##*:}" "$output" 2>&1 | grep -v 'logback\|^$' || true
test -s "$output"
done
# RIP as Java FILIUS runs it: rip-chain's routers, each with the core's seed
# for its pauses (RipRun); frames, table changes and the ping. Real time.
for run in converge:60000 expire:135000; do
story="${run%%:*}"
output="$root/packages/core/test/scenarios/rip-java-$story.java.json"
rm -f "$output"
HOME="$here/.build/home" xvfb-run -a java -cp "$classpath:$here/.build" RipRun \
"$root/packages/core/test/scenarios/rip-chain.scenario.json" "$story" "${run##*:}" "$output" 2>&1 | grep -v 'logback\|^$' || true
test -s "$output"
done
# ARP as Java FILIUS runs it: sends to addresses no card has on arp-routed's
# network (ArpRun); frames and the calls, for the core's ARP comparison.
for story in pingLan pingRouted udpTwice udpBehind routedUdpBehind routedPingBesideUdp routedPingBehindPing; do
output="$root/packages/core/test/scenarios/arp-java-$story.java.json"
rm -f "$output"
HOME="$here/.build/home" xvfb-run -a java -cp "$classpath:$here/.build" ArpRun \
"$root/packages/core/test/scenarios/arp-routed.scenario.json" "$story" 16000 "$output" 2>&1 | grep -v 'logback\|^$' || true
test -s "$output"
done
# WLAN as Java FILIUS runs it: pings over wireless cables, a plain cable and
# to a host on the switch's SSID without a cable (WlanRun); frames and calls.
for story in pingWired pingWireless pingWithoutCable pingFromWithoutCable; do
output="$root/packages/core/test/scenarios/wlan-java-$story.java.json"
rm -f "$output"
HOME="$here/.build/home" xvfb-run -a java -cp "$classpath:$here/.build" WlanRun \
"$root/packages/core/test/scenarios/wlan-lan.scenario.json" "$story" 12000 "$output" 2>&1 | grep -v 'logback\|^$' || true
test -s "$output"
done
# The echo server and the generic client as Java FILIUS runs them, on
# tcp-lan's network (EchoRun); frames and each program's window lines.
for run in exchange:12000 closedPort:20000 noRoute:8000 notConnected:3000 serverOff:14000 reconnect:12000 \
twoClients:11000 otherPort:22000; do
story="${run%%:*}"
output="$root/packages/core/test/scenarios/echo-java-$story.java.json"
rm -f "$output"
HOME="$here/.build/home" xvfb-run -a java -cp "$classpath:$here/.build" EchoRun \
"$root/packages/core/test/scenarios/tcp-lan.scenario.json" "$story" "${run##*:}" "$output" 2>&1 | grep -v 'logback\|^$' || true
test -s "$output"
done
# The web server and the web browser as Java FILIUS runs them, on web-lan's
# network (WebRun); frames, the server's window lines, the browser's pages and
# images, and the server's files.
for run in page:8000 byName:12000 notFound:6000 vhost:14000 noServer:14000 unresolved:6000 post:8000 \
encoded:10000 traversal:6000 caseInsensitive:8000 raw:14000; do
story="${run%%:*}"
output="$root/packages/core/test/scenarios/web-java-$story.java.json"
rm -f "$output"
HOME="$here/.build/home" xvfb-run -a java -cp "$classpath:$here/.build" WebRun \
"$root/packages/core/test/scenarios/web-lan.scenario.json" "$story" "${run##*:}" "$output" 2>&1 | grep -v 'logback\|^$' || true
test -s "$output"
done
# The pages of routers and home routers as Java FILIUS serves them
# (RouterWebRun): router-web, nat-home and rip-chain. Java's router server
# sometimes never listens (a race in setAktiv): a run without a page is
# repeated.
for run in router-web:routerIndex:6000 router-web:routerRoutes:6000 router-web:routerLog:12000 router-web:routerKonfig:6000 \
router-web:konfigIcmp:12000 router-web:konfigBlock:30000 \
nat-home:gatewayIndex:9000 nat-home:gatewayFromWan:15000 rip-chain:ripRoutes:46000; do
network="${run%%:*}"; rest="${run#*:}"; story="${rest%%:*}"
output="$root/packages/core/test/scenarios/routerweb-java-$story.java.json"
for attempt in 1 2 3; do
rm -f "$output"
HOME="$here/.build/home" xvfb-run -a java -cp "$classpath:$here/.build" RouterWebRun \
"$root/packages/core/test/scenarios/$network.scenario.json" "$story" "${rest##*:}" "$output" 2>&1 | grep -v 'logback\|^$' || true
grep -q '"page 200' "$output" && break
done
test -s "$output"
done
# The firewall settings page (konfig) fed with what a browser posts, in both
# languages (KonfigCases; packages/core/test/firewallSettings.test.ts).
for language in de en; do
output="$root/packages/core/test/firewall-settings.$language.java.json"
rm -f "$output"
HOME="$here/.build/home" xvfb-run -a java -cp "$classpath:$here/.build" KonfigCases "$language" \
"$root/packages/core/test/firewall-settings.cases.txt" "$output" 2>&1 | grep -v 'logback\|^$' || true
test -s "$output"
done
# The e-mail server as Java FILIUS runs it (EmailRun on mail-lan), and its
# SMTP and POP3 workers fed without a network, in both languages (MailCases);
# the e-mail program with two servers (EmailClientRun). The JVM runs in the
# language's locale: a server's notice carries DateFormat's date in it.
german="-Duser.language=de -Duser.country=DE"
for run in smtp:16000 smtpErrors:25000 pop3:36000 pop3Errors:20000; do
story="${run%%:*}"
output="$root/packages/core/test/scenarios/email-java-$story.java.json"
rm -f "$output"
HOME="$here/.build/home" xvfb-run -a java $german -cp "$classpath:$here/.build" EmailRun \
"$root/packages/core/test/scenarios/mail-lan.scenario.json" "$story" "${run##*:}" "$output" 2>&1 | grep -v 'logback\|^$' || true
test -s "$output"
done
for language in de:DE en:GB; do
output="$root/packages/core/test/email-server.${language%%:*}.java.json"
rm -f "$output"
HOME="$here/.build/home" xvfb-run -a java -Duser.language="${language%%:*}" -Duser.country="${language##*:}" -cp "$classpath:$here/.build" \
MailCases "${language%%:*}" "$root/packages/core/test/email-server.cases.txt" "$output" 2>&1 | grep -v 'logback\|^$' || true
test -s "$output"
done
for run in send:15000 fetch:10000 byName:35000 wrongPass:8000 noServer:15000 unknownHost:15000; do
story="${run%%:*}"
output="$root/packages/core/test/scenarios/email-client-java-$story.java.json"
rm -f "$output"
HOME="$here/.build/home" xvfb-run -a java $german -cp "$classpath:$here/.build" EmailClientRun \
"$root/packages/core/test/scenarios/mail-lan.scenario.json" "$story" "${run##*:}" "$output" 2>&1 | grep -v 'logback\|^$\|^\s*at ' || true
test -s "$output"
done
# The command line fed with lines as typed, without a running network, in
# both languages (TerminalCases; packages/core/test/terminal.test.ts).
for language in de en; do
output="$root/packages/core/test/terminal.$language.java.json"
rm -f "$output"
HOME="$here/.build/home" xvfb-run -a java -cp "$classpath:$here/.build" TerminalCases "$language" \
"$root/packages/core/test/scenarios/router-web.scenario.json" "$root/packages/core/test/terminal.cases.txt" "$output" 2>&1 | grep -v 'logback\|^$' || true
test -s "$output"
done
# The Gnutella program joining peers, searching and downloading on terminal-net (GnutellaRun;
# packages/core/test/gnutellaJava.test.ts).
for run in pair:6000 chain:9000 twoPaths:15000 full:11000 reset:7000 errors:40000 search:29000 searchBoth:13000; do
story="${run%%:*}"
output="$root/packages/core/test/scenarios/gnutella-java-$story.java.json"
rm -f "$output"
HOME="$here/.build/home" xvfb-run -a java $german -cp "$classpath:$here/.build" GnutellaRun \
"$root/packages/core/test/scenarios/terminal-net.scenario.json" "$story" "${run##*:}" "$output" 2>&1 | grep -v 'logback\|^$\|^\s*at \|scrollpane' || true
test -s "$output"
done
# What the file explorer and the text editor do to a host's files, without a
# running network, in both languages (FileCases; packages/core/test/filePrograms.test.ts).
for language in de en; do
output="$root/packages/core/test/file-programs.$language.java.json"
rm -f "$output"
HOME="$here/.build/home" xvfb-run -a java -cp "$classpath:$here/.build" FileCases "$language" \
"$root/packages/core/test/scenarios/router-web.scenario.json" "$root/packages/core/test/file-programs.cases.txt" "$output" 2>&1 | grep -v 'logback\|^$' || true
test -s "$output"
done
# The command line's network commands on terminal-net, typed at set times
# (TerminalRun; packages/core/test/terminalJava.test.ts), in the German locale.
for run in pingLan:8000 pingRouted:13000 pingNobody:49000 pingUnreachable:45000 pingBroadcast:27000 pingSelf:17000 \
pingErrors:14000 interrupt:16000 dns:15000 dnsTimeout:80000 arp:11000 netstat:10000 traceLan:4000 \
traceRouted:6000 traceUnreachable:35000 traceNoRoute:4000 traceNobody:12000 traceSelf:3500 traceErrors:20000 \
traceInterrupt:12000 tcpdump:10000; do
story="${run%%:*}"
output="$root/packages/core/test/scenarios/terminal-java-$story.java.json"
rm -f "$output"
HOME="$here/.build/home" xvfb-run -a java $german -cp "$classpath:$here/.build" TerminalRun \
"$root/packages/core/test/scenarios/terminal-net.scenario.json" "$story" "${run##*:}" "$output" 2>&1 | grep -v 'logback\|^$\|^\s*at ' || true
test -s "$output"
done
# Every kind of device as FILIUS' palette makes it, saved as FILIUS saves
# (NewDeviceRun): what the editor's new devices must be (packages/doc/test/devices.test.ts).
output="$root/packages/doc/test/fixtures/new-devices.fls"
rm -f "$output"
HOME="$here/.build/home" xvfb-run -a java -cp "$classpath:$here/.build" NewDeviceRun "$output" 2>&1 | grep -v 'logback\|^$' || true
test -s "$output"
# FILIUS' own examples as Java FILIUS runs them, opened and started as FILIUS
# does (ExampleRun): the acceptance of F2 (packages/fls/test/examplesJava.test.ts)
# and the classics of F3 (web, email, gnutella; packages/fls/test/classicsJava.test.ts).
for run in internetwork_komplett:routing:12000 einfaches_rechnernetz_komplett:dhcp:20000 dns_server:dns:12000 \
nat_with_mapped_port:nat:15000 Internet_Komplett_mit_eMail_Webserver_Intranet_Portforwarding_Firewall_DHCP_DE:firewall:16000 \
internetwork_komplett:web:12000 Internet_Komplett_mit_eMail_Webserver_Intranet_Portforwarding_Firewall_DHCP_DE:email:40000 \
zwei_rechnernetze_komplett:gnutella:26000; do
file="${run%%:*}"; rest="${run#*:}"; story="${rest%%:*}"
output="$root/packages/fls/test/examples/$story.java.json"
rm -f "$output"
HOME="$here/.build/home" xvfb-run -a java -cp "$classpath:$here/.build" ExampleRun \
"$root/corpus/java-examples/$file.fls" "$story" "${rest##*:}" "$output" 2>&1 | grep -v 'logback\|^$' || true
test -s "$output"
done