mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-25 00:11:07 +00:00
Make fs test loopable
This commit is contained in:
parent
00747ddd1f
commit
d564003e1c
@ -53,6 +53,9 @@ set config {
|
||||
</start>
|
||||
<start name="test-libc_ffat">
|
||||
<resource name="RAM" quantum="2M"/>
|
||||
<config>
|
||||
<iterations value="1"/>
|
||||
</config>
|
||||
</start>
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,9 @@ install_config {
|
||||
</start>
|
||||
<start name="test-libc_fs">
|
||||
<resource name="RAM" quantum="2M"/>
|
||||
<config>
|
||||
<iterations value="1"/>
|
||||
</config>
|
||||
</start>
|
||||
</config>
|
||||
}
|
||||
|
@ -449,7 +449,10 @@ class Plugin : public Libc::Plugin
|
||||
ffat_flags |= FA_WRITE;
|
||||
|
||||
if ((flags & O_CREAT) == O_CREAT)
|
||||
if ((flags & O_EXCL) == O_EXCL)
|
||||
ffat_flags |= FA_CREATE_NEW;
|
||||
else
|
||||
ffat_flags |= FA_CREATE_ALWAYS;
|
||||
|
||||
FRESULT res = f_open(&ffat_file, pathname, ffat_flags);
|
||||
|
||||
|
@ -12,6 +12,9 @@
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <os/config.h>
|
||||
|
||||
/* libc includes */
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
@ -38,19 +41,23 @@ int main(int argc, char *argv[])
|
||||
int ret, fd;
|
||||
|
||||
char const *dir_name = "/testdir";
|
||||
char const *dir_name_long = "testdir long";
|
||||
char const *file_name = "test.tst";
|
||||
char const *pattern = "a single line of text";
|
||||
|
||||
unsigned int iterations = 1;
|
||||
|
||||
try {
|
||||
Genode::config()->xml_node().sub_node("iterations").attribute("value").value(&iterations);
|
||||
} catch(...) { }
|
||||
|
||||
for (unsigned int i = 0; i < iterations; i++) {
|
||||
|
||||
/* create directory (short name) */
|
||||
CALL_AND_CHECK(ret, mkdir(dir_name, 0777), ret == 0, "dir_name=%s", dir_name);
|
||||
CALL_AND_CHECK(ret, mkdir(dir_name, 0777), ((ret == 0) || (errno == EEXIST)), "dir_name=%s", dir_name);
|
||||
|
||||
/* change to new directory */
|
||||
CALL_AND_CHECK(ret, chdir(dir_name), ret == 0, "dir_name=%s", dir_name);
|
||||
|
||||
/* create directory (long name) */
|
||||
CALL_AND_CHECK(ret, mkdir(dir_name_long, 0777), ret == 0, "dir_name_long=%s", dir_name_long);
|
||||
|
||||
/* write pattern to a file */
|
||||
CALL_AND_CHECK(fd, open(file_name, O_CREAT | O_WRONLY), fd >= 0, "file_name=%s", file_name);
|
||||
size_t count = strlen(pattern);
|
||||
@ -96,5 +103,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (i < (iterations - 1))
|
||||
sleep(2);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user