Debian Codegraph @

libstdc++-v3/testsuite/27_io/filesystem/operations/copy_file_108178.cc

raw symbols SCIP
1 // { dg-do run { target c++17 } }
2 // { dg-require-filesystem-ts "" }
3
4 // C++17 30.10.15.4 Copy [fs.op.copy_file]
5
6 #include <filesystem>
7 #include <fstream>
8 #include <unistd.h> // getpid
9 #include <testsuite_fs.h>
10 #include <testsuite_hooks.h>
11
12 namespace fs = std::filesystem;
13
14 void
15 test_procfs() // PR libstdc++/108178
16 {
17 auto pid = ::getpid();
18 std::string from = "/proc/" + std::to_string(pid) + "/status";
19 if (fs::exists(from))
20 {
21 auto to = __gnu_test::nonexistent_path();
22 fs::copy_file(from, to);
23 std::ifstream f(to);
24 VERIFY(f.is_open());
25 VERIFY(f.peek() != std::char_traits<char>::eof());
26 fs::remove(to);
27 }
28 }
29
30 int main()
31 {
32 test_procfs();
33 }