summaryrefslogtreecommitdiffstats
path: root/Tests/CTestTestResourceLock/lockFile.c
diff options
context:
space:
mode:
authorZach Mullen <zach.mullen@kitware.com>2010-03-03 15:32:03 (GMT)
committerZach Mullen <zach.mullen@kitware.com>2010-03-03 15:33:09 (GMT)
commit2fd9b8072bb15e16446e15c1165566d4a238e4cc (patch)
treec302a7efb0e2a4df2154f1c591e0ae8a4698286e /Tests/CTestTestResourceLock/lockFile.c
parentadca29a5beca6f25d1224176584ea7c4ef0bf360 (diff)
downloadCMake-2fd9b8072bb15e16446e15c1165566d4a238e4cc.zip
CMake-2fd9b8072bb15e16446e15c1165566d4a238e4cc.tar.gz
CMake-2fd9b8072bb15e16446e15c1165566d4a238e4cc.tar.bz2
Add unit test for RESOURCE_LOCK test property
Diffstat (limited to 'Tests/CTestTestResourceLock/lockFile.c')
-rw-r--r--Tests/CTestTestResourceLock/lockFile.c31
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..f8edc3f
--- /dev/null
+++ b/Tests/CTestTestResourceLock/lockFile.c
@@ -0,0 +1,31 @@
+#include <stdio.h>
+
+/* Disable deprecation warning for fopen */
+#define _CRT_SECURE_NO_WARNINGS
+
+/*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);
+}