Skip to contentSkip to conversation

selftests: net: add socat syslog for PPPoL2TP

PATCH Superseded Qingfang Deng 2 participants 3 messages May 26

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: net: add socat syslog for PPPoL2TP

As done in pppoe.sh, start socat as the syslog listener. In case the test fails, dump its log to see what's going on.

---
 tools/testing/selftests/net/ppp/pppol2tp.sh | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
tools/testing/selftests/net/ppp/pppol2tp.sh +15 -0
index 5b592785f1f9..96786267ccc7 100755
@@ -9,10 +9,12 @@ OUTER_IP_SERVER="172.16.1.1"
 OUTER_IP_CLIENT="172.16.1.2"
 
 PPPOL2TP_DIR=$(mktemp -d /tmp/pppol2tp.XXXXXX)
+PPPOL2TP_LOG="$PPPOL2TP_DIR/l2tp.log"
 
 # shellcheck disable=SC2329
 cleanup() {
 	cleanup_all_ns
+	[ -n "$SOCAT_PID" ] && kill_process "$SOCAT_PID"
 	rm -rf "$PPPOL2TP_DIR"
 }
 
@@ -31,6 +33,10 @@ ip -netns "$NS_CLIENT" link set "$VETH_CLIENT" up
 ip -netns "$NS_SERVER" address add dev "$VETH_SERVER" "$OUTER_IP_SERVER" peer "$OUTER_IP_CLIENT"
 ip -netns "$NS_CLIENT" address add dev "$VETH_CLIENT" "$OUTER_IP_CLIENT" peer "$OUTER_IP_SERVER"
 
+# Start socat as syslog listener
+socat -v -u UNIX-RECV:/dev/log OPEN:/dev/null > "$PPPOL2TP_LOG" 2>&1 &
+SOCAT_PID=$!
+
 # Generate configuration files
 cat > "$PPPOL2TP_DIR/l2tp-server.conf" <<EOF
 [global]
@@ -80,6 +86,15 @@ ppp_test_connectivity
 
 log_test "PPPoL2TP"
 
+# Dump syslog messages if the test failed
+if [ "$RET" -ne 0 ]; then
+	while read -r _sign _date _time len _from _to
+	do      len=${len##*=}
+		read -n "$len" -r LINE
+		echo "$LINE"
+	done < "$PPPOL2TP_LOG"
+fi
+
 # Recursion test
 RET=0
 # Delete route to LNS IP
Signature · 1 line
2.43.0
#1 lore raw

Hi Qingfang,

Quoted 2 lines · Qingfang Deng

As done in pppoe.sh, start socat as the syslog listener. In case the test fails, dump its log to see what's going on.

(...)

Quoted 4 lines
tools/testing/selftests/net/ppp/pppol2tp.sh +0 -0
index 5b592785f1f9..96786267ccc7 100755

(...)

tools/testing/selftests/net/ppp/pppol2tp.sh ppp_test_connectivity · line 90

Quoted 2 lines
tools/testing/selftests/net/ppp/pppol2tp.sh +2 -0
+# Dump syslog messages if the test failed
+if [ "$RET" -ne 0 ]; then

This only checks for errors with the first test, not with the second one below. Should you create a new helper and call it here and below? Or only once at the end, using ${EXIT_STATUS} instead?

tools/testing/selftests/net/ppp/pppol2tp.sh ppp_test_connectivity · line 100

Quoted 10 lines
tools/testing/selftests/net/ppp/pppol2tp.sh +7 -0
+	while read -r _sign _date _time len _from _to
+	do      len=${len##*=}
+		read -n "$len" -r LINE
+		echo "$LINE"
+	done < "$PPPOL2TP_LOG"
+fi
+
 # Recursion test
 RET=0
 # Delete route to LNS IP

Cheers,
Matt

#2 lore raw
Quoted 15 lines · Matthieu Baerts

Hi Qingfang,

Quoted 2 lines · Qingfang Deng

As done in pppoe.sh, start socat as the syslog listener. In case the test fails, dump its log to see what's going on.

(...)

Quoted 4 lines
tools/testing/selftests/net/ppp/pppol2tp.sh +0 -0
index 5b592785f1f9..96786267ccc7 100755

(...)

Quoted 6 lines

tools/testing/selftests/net/ppp/pppol2tp.sh ppp_test_connectivity · line 90

Quoted 2 lines
tools/testing/selftests/net/ppp/pppol2tp.sh +2 -0
+# Dump syslog messages if the test failed
+if [ "$RET" -ne 0 ]; then

This only checks for errors with the first test, not with the second one below. Should you create a new helper and call it here and below? Or only once at the end, using ${EXIT_STATUS} instead?

I'll move it to the end, thanks.

Quoted 14 lines

tools/testing/selftests/net/ppp/pppol2tp.sh ppp_test_connectivity · line 100

Quoted 10 lines
tools/testing/selftests/net/ppp/pppol2tp.sh +7 -0
+	while read -r _sign _date _time len _from _to
+	do      len=${len##*=}
+		read -n "$len" -r LINE
+		echo "$LINE"
+	done < "$PPPOL2TP_LOG"
+fi
+
  # Recursion test
  RET=0
  # Delete route to LNS IP

Cheers,
Matt