summaryrefslogtreecommitdiff
path: root/test/testprog.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/testprog.cc')
-rw-r--r--test/testprog.cc49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/testprog.cc b/test/testprog.cc
new file mode 100644
index 0000000..dbfb665
--- /dev/null
+++ b/test/testprog.cc
@@ -0,0 +1,49 @@
+#include <iostream>
+#include <fstream>
+#include <string>
+
+extern const char **environ; // see 'man environ'
+
+int main(int argc, const char* argv[])
+{
+ if(argc < 2)
+ {
+ return 0;
+ }
+
+ std::string cmd = argv[1];
+
+ if(cmd == "envdump")
+ {
+ if(argc < 3)
+ {
+ return 0;
+ }
+ std::ofstream ostrm(argv[2], std::ios::binary);
+ for(auto current = environ; *current; ++current)
+ {
+ ostrm << (*current) << "\n";
+ }
+ }
+
+ if(cmd == "retval")
+ {
+ if(argc < 3)
+ {
+ return 0;
+ }
+ return std::stoi(argv[2]);
+ }
+
+ if(cmd == "abort")
+ {
+ abort();
+ }
+
+ if(cmd == "throw")
+ {
+ throw "ouch";
+ }
+
+ return 0;
+}