[riot-notifications] [RIOT-OS/RIOT] pkg/spiffs: implement statvfs and improve doc (#7345)

Joakim NohlgÄrd notifications at github.com
Mon Dec 11 12:18:11 CET 2017


gebart approved this pull request.

Changes look good, only missing some parentheses in the unit test.
`fstatvfs` could be trivially implemented as a wrapper for statvfs, but I don't demand that this should be done in this PR.

> +
+    int fd = vfs_open("/test-spiffs/test.txt", O_CREAT | O_RDWR, 0);
+    TEST_ASSERT(fd >= 0);
+
+    res = vfs_write(fd, buf, sizeof(buf));
+    TEST_ASSERT(res == sizeof(buf));
+
+    res = vfs_close(fd);
+    TEST_ASSERT_EQUAL_INT(0, res);
+
+    res = vfs_statvfs("/test-spiffs/", &stat2);
+    TEST_ASSERT_EQUAL_INT(0, res);
+
+    TEST_ASSERT_EQUAL_INT(1, stat2.f_bsize);
+    TEST_ASSERT_EQUAL_INT(1, stat2.f_frsize);
+    TEST_ASSERT(sizeof(buf) <= stat1.f_bfree - stat2.f_bfree);

put some parentheses around the subtraction

> @@ -326,6 +326,37 @@ static void tests_spiffs_rename(void)
     TEST_ASSERT_EQUAL_INT(0, res);
 }
 
+static void tests_spiffs_statvfs(void)
+{
+    const char buf[] = "TESTSTRING";
+    struct statvfs stat1;
+    struct statvfs stat2;
+
+    int res = vfs_statvfs("/test-spiffs/", &stat1);
+    TEST_ASSERT_EQUAL_INT(0, res);
+    TEST_ASSERT_EQUAL_INT(1, stat1.f_bsize);
+    TEST_ASSERT_EQUAL_INT(1, stat1.f_frsize);
+    TEST_ASSERT(_dev->pages_per_sector * _dev->page_size * _dev->sector_count >=

parens

> +    int fd = vfs_open("/test-spiffs/test.txt", O_CREAT | O_RDWR, 0);
+    TEST_ASSERT(fd >= 0);
+
+    res = vfs_write(fd, buf, sizeof(buf));
+    TEST_ASSERT(res == sizeof(buf));
+
+    res = vfs_close(fd);
+    TEST_ASSERT_EQUAL_INT(0, res);
+
+    res = vfs_statvfs("/test-spiffs/", &stat2);
+    TEST_ASSERT_EQUAL_INT(0, res);
+
+    TEST_ASSERT_EQUAL_INT(1, stat2.f_bsize);
+    TEST_ASSERT_EQUAL_INT(1, stat2.f_frsize);
+    TEST_ASSERT(sizeof(buf) <= stat1.f_bfree - stat2.f_bfree);
+    TEST_ASSERT(sizeof(buf) <= stat1.f_bavail - stat2.f_bavail);

parens

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/7345#pullrequestreview-82455793
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20171211/8603ab6f/attachment.html>


More information about the notifications mailing list