tools: Allow batch command processing by nfdc
Change-Id: Ia6f70fed88f2d4c918e2ca2b786222840dbd9076
Refs: #5169
diff --git a/tests/tools/nfdc/README.md b/tests/tools/nfdc/README.md
new file mode 100644
index 0000000..647a012
--- /dev/null
+++ b/tests/tools/nfdc/README.md
@@ -0,0 +1,21 @@
+# Manual test for nfdc batch mode
+
+To run the test from this folder
+
+ nfdc -f nfdc-batch.t.txt
+
+ nfdc --batch nfdc-batch.t.txt
+
+If everything works, it should execute 3 commands with example output like this
+in both cases (can be different depending on the NFD runtime):
+
+ face-exists id=263 local=udp4://192.168.100.240:6363 remote=udp4://192.0.2.1:6363 persistency=persistent reliability=off congestion-marking=on congestion-marking-interval=100ms default-congestion-threshold=65536B mtu=8800
+ route-add-accepted prefix=/ nexthop=264 origin=static cost=0 flags=child-inherit expires=never
+ route-add-accepted prefix=/test2/foo%20bar nexthop=265 origin=static cost=0 flags=child-inherit expires=never
+ CS information:
+ capacity=65536
+ admit=on
+ serve=on
+ nEntries=14
+ nHits=0
+ nMisses=53
diff --git a/tests/tools/nfdc/help.t.cpp b/tests/tools/nfdc/help.t.cpp
index 6e899ba..c5d5012 100644
--- a/tests/tools/nfdc/help.t.cpp
+++ b/tests/tools/nfdc/help.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -47,7 +47,7 @@
ExecuteCommand dummyExecute = [] (ExecuteContext&) { BOOST_ERROR("should not be called"); };
boost::test_tools::output_test_stream out;
- const std::string header("nfdc [-h|--help] [-V|--version] <command> [<args>]\n\n");
+ const std::string header("nfdc [-h|--help] [-V|--version] [-f|--batch <batch-file>] [<command> [<args>]]\n\n");
const std::string trailer("\nSee 'nfdc help <command>' to read about a specific subcommand.\n");
helpList(out, parser);
diff --git a/tests/tools/nfdc/nfdc-batch.t.txt b/tests/tools/nfdc/nfdc-batch.t.txt
new file mode 100644
index 0000000..22fc042
--- /dev/null
+++ b/tests/tools/nfdc/nfdc-batch.t.txt
@@ -0,0 +1,14 @@
+ "face" create "udp://192.0.2.1"
+
+route add / udp://192.0.2.2
+
+route \
+ add \
+ "/test2/foo bar" \
+ 'udp://192.0.2.3'
+
+# route test
+ ##### route test
+ # route test
+
+cs info