From 636c7dc17286d93d788c741d15fd756aeda066d5 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 5 May 2024 20:07:13 +0200 Subject: Adding upstream version 1.8.2.3. Signed-off-by: Daniel Baumann --- test/interactive-helper/test_fileutl.cc | 44 +++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 test/interactive-helper/test_fileutl.cc (limited to 'test/interactive-helper/test_fileutl.cc') diff --git a/test/interactive-helper/test_fileutl.cc b/test/interactive-helper/test_fileutl.cc new file mode 100644 index 0000000..6c29b74 --- /dev/null +++ b/test/interactive-helper/test_fileutl.cc @@ -0,0 +1,44 @@ +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +static void callsystem(std::string const &call) +{ + auto ret = system(call.c_str()); + if (WIFEXITED(ret) == false || WEXITSTATUS(ret) != 0) + _error->Error("Calling %s failed!", call.c_str()); +} + +int main(int, char ** argv) +{ + auto const pid = getpid(); + std::string ls; + strprintf(ls, "ls -l /proc/%d/fd", pid); + callsystem(ls); + FileFd t; + t.Open(argv[1], FileFd::ReadOnly, FileFd::Extension); + callsystem(ls); + char buf[1024]; + unsigned long long act; + while (t.Read(buf, sizeof(buf), &act)) + if (act == 0) + break; + callsystem(ls); + t.Seek(5); + callsystem(ls); + t.Close(); + callsystem(ls); + auto const ret = _error->PendingError(); + _error->DumpErrors(); + return ret; +} -- cgit v1.2.3