diff options
Diffstat (limited to 'Tests/CTestTestResourceLock/lockFile.c')
-rw-r--r-- | Tests/CTestTestResourceLock/lockFile.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Tests/CTestTestResourceLock/lockFile.c b/Tests/CTestTestResourceLock/lockFile.c new file mode 100644 index 0000000..a6a4dc0 --- /dev/null +++ b/Tests/CTestTestResourceLock/lockFile.c @@ -0,0 +1,31 @@ +#include <stdio.h> + +/* Disable deprecation warning for fopen */ +#pragma warning(disable: 4996) + +/*if run serially, works fine. + If run in parallel, someone will attempt to delete + a locked file, which will fail */ +int main(int argc, char** argv) +{ + FILE* file; + int i; + const char* fname; + if(argc >= 2) + { + fname = argv[1]; + } + else + { + fname = "lockedFile.txt"; + } + file = fopen(fname, "w"); + + for(i = 0; i < 10000; i++) + { + fprintf(file, "%s", "x"); + fflush(file); + } + fclose(file); + return remove(fname); +} |