TZIVI-254: IVI needs a newer version of cmake
[profile/ivi/cmake.git] / Tests / CTestTestResourceLock / lockFile.c
1 #include <stdio.h>
2
3 /* Disable deprecation warning for fopen */
4 #pragma warning(disable: 4996)
5
6 /*if run serially, works fine.
7   If run in parallel, someone will attempt to delete
8   a locked file, which will fail */
9 int main(int argc, char** argv)
10 {
11   FILE* file;
12   int i;
13   const char* fname;
14   if(argc >= 2)
15     {
16     fname = argv[1];
17     }
18   else
19     {
20     fname = "lockedFile.txt";
21     }
22   file = fopen(fname, "w");
23
24   for(i = 0; i < 10000; i++)
25     {
26     fprintf(file, "%s", "x");
27     fflush(file);
28     }
29   fclose(file);
30   return remove(fname);
31 }