--- /dev/null
+#
+# Test the radutmp module
+#
--- /dev/null
+radutmp {
+ filename = $ENV{MODULE_TEST_DIR}radutmp
+ username = %{User-Name}
+ caller_id = yes
+}
+
+exec {
+ wait = yes
+ shell_escape = yes
+ timeout = 1
+ output_pairs = &control
+ program = "./build/bin/local/radwho -D share/dictionary -F $ENV{MODULE_TEST_DIR}/radutmp -u %{User-Name} -c -R"
+}
--- /dev/null
+#
+# Input packet
+#
+Packet-Type = Access-Request
+User-Name = 'user0@example.org'
+NAS-Port = 17826193
+NAS-IP-Address = 192.0.2.10
+Calling-Station-Id = 00-11-22-33-44-55
+Framed-IP-Address = 198.51.100.59
+Acct-Status-Type = Start
+Acct-Delay-Time = 1
+Acct-Input-Octets = 0
+Acct-Output-Octets = 0
+Acct-Session-Id = '00000001'
+Acct-Session-Time = 0
+Acct-Input-Packets = 0
+Acct-Output-Packets = 0
+Acct-Input-Gigawords = 0
+Acct-Output-Gigawords = 0
+Event-Timestamp = 'Feb 1 2024 08:28:58 GMT'
+NAS-Port-Type = Ethernet
+NAS-Port-Id = 'port 001'
+Service-Type = Framed-User
+Framed-Protocol = PPP
+Idle-Timeout = 0
+Session-Timeout = 604800
+
+#
+# Expected answer
+#
+# There's not an Accounting-Failed packet type in RADIUS...
+#
+Packet-Type == Access-Accept
--- /dev/null
+#
+# Remove any historic radutmp file
+#
+%file.rm("$ENV{MODULE_TEST_DIR}/radutmp")
+
+#
+# Call the module in accounting context to record the user's session
+#
+radutmp.accounting
+
+if (!ok) {
+ test_fail
+}
+
+#
+# Runs radwho to read back stored data as pairs into &control
+#
+exec
+
+if !(&NAS-Port == &control.NAS-Port) {
+ test_fail
+}
+
+#
+# Use an Interim-Update and different Framed-IP-Address to check record update
+#
+&Framed-IP-Address := 10.0.10.100
+&Acct-Status-Type := Interim-Update
+
+radutmp.accounting
+
+if (!ok) {
+ test_fail
+}
+
+&control := {}
+
+exec
+
+if !(&Framed-IP-Address == &control.Framed-IP-Address) {
+ test_fail
+}
+
+#
+# Now use a Stop to clear the user's session
+#
+&Acct-Status-Type := Stop
+
+radutmp.accounting
+
+if (!ok) {
+ test_fail
+}
+
+&control := {}
+
+exec
+
+if (&control.NAS-Port) {
+ test_fail
+}
+
+#
+# Tidy up
+#
+%file.rm("$ENV{MODULE_TEST_DIR}/radutmp")
+
+test_pass