diff options
Diffstat (limited to 'test/testprog.cc')
-rw-r--r-- | test/testprog.cc | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/test/testprog.cc b/test/testprog.cc new file mode 100644 index 0000000..faf1498 --- /dev/null +++ b/test/testprog.cc @@ -0,0 +1,53 @@ +#include <iostream> +#include <fstream> +#include <string> +#include <signal.h> + +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 == "segfault") + { + raise(SIGSEGV); + } + + if(cmd == "throw") + { + throw "ouch"; + } + + return 0; +} |