"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/fs_tests.c" between
vnstat-2.7.tar.gz and vnstat-2.8.tar.gz

About: vnStat is a console-based network traffic monitor (using the /proc filesystem).

fs_tests.c  (vnstat-2.7):fs_tests.c  (vnstat-2.8)
#include "common.h" #include "common.h"
#include "vnstat_tests.h" #include "vnstat_tests.h"
#include "fs_tests.h" #include "fs_tests.h"
#include "cfg.h" #include "cfg.h"
#include "fs.h" #include "fs.h"
START_TEST(fileexists_with_no_file) START_TEST(fileexists_with_no_file)
{ {
char testfile[512]; char testfile[512];
defaultcfg();
snprintf(testfile, 512, "%s/no_file", TESTDIR); snprintf(testfile, 512, "%s/no_file", TESTDIR);
ck_assert_int_eq(remove_directory(TESTDIR), 1); ck_assert_int_eq(remove_directory(TESTDIR), 1);
ck_assert_int_eq(fileexists(""), 0); ck_assert_int_eq(fileexists(""), 0);
ck_assert_int_eq(fileexists(testfile), 0); ck_assert_int_eq(fileexists(testfile), 0);
} }
END_TEST END_TEST
START_TEST(fileexists_with_file) START_TEST(fileexists_with_file)
{ {
char testfile[512]; char testfile[512];
defaultcfg();
snprintf(testfile, 512, "%s/dummy_file", TESTDBDIR); snprintf(testfile, 512, "%s/dummy_file", TESTDBDIR);
ck_assert_int_eq(remove_directory(TESTDIR), 1); ck_assert_int_eq(remove_directory(TESTDIR), 1);
ck_assert_int_eq(clean_testdbdir(), 1); ck_assert_int_eq(clean_testdbdir(), 1);
ck_assert_int_eq(create_zerosize_dbfile("dummy_file"), 1); ck_assert_int_eq(create_zerosize_dbfile("dummy_file"), 1);
ck_assert_int_eq(fileexists(testfile), 1); ck_assert_int_eq(fileexists(testfile), 1);
} }
END_TEST END_TEST
START_TEST(direxists_with_no_dir) START_TEST(direxists_with_no_dir)
{ {
defaultcfg();
ck_assert_int_eq(remove_directory(TESTDIR), 1); ck_assert_int_eq(remove_directory(TESTDIR), 1);
ck_assert_int_eq(direxists(""), 0); ck_assert_int_eq(direxists(""), 0);
ck_assert_int_eq(direxists(TESTDIR), 0); ck_assert_int_eq(direxists(TESTDIR), 0);
} }
END_TEST END_TEST
START_TEST(direxists_with_dir) START_TEST(direxists_with_dir)
{ {
defaultcfg();
ck_assert_int_eq(remove_directory(TESTDIR), 1); ck_assert_int_eq(remove_directory(TESTDIR), 1);
ck_assert_int_eq(clean_testdbdir(), 1); ck_assert_int_eq(clean_testdbdir(), 1);
ck_assert_int_eq(direxists(TESTDIR), 1); ck_assert_int_eq(direxists(TESTDIR), 1);
ck_assert_int_eq(direxists(TESTDBDIR), 1); ck_assert_int_eq(direxists(TESTDBDIR), 1);
} }
END_TEST END_TEST
START_TEST(mkpath_with_no_dir) START_TEST(mkpath_with_no_dir)
{ {
defaultcfg();
ck_assert_int_eq(remove_directory(TESTDIR), 1); ck_assert_int_eq(remove_directory(TESTDIR), 1);
ck_assert_int_eq(mkpath("", 0775), 0); ck_assert_int_eq(mkpath("", 0775), 0);
} }
END_TEST END_TEST
START_TEST(mkpath_with_dir) START_TEST(mkpath_with_dir)
{ {
defaultcfg();
ck_assert_int_eq(remove_directory(TESTDIR), 1); ck_assert_int_eq(remove_directory(TESTDIR), 1);
ck_assert_int_eq(direxists(TESTDIR), 0); ck_assert_int_eq(direxists(TESTDIR), 0);
ck_assert_int_eq(direxists(TESTDBDIR), 0); ck_assert_int_eq(direxists(TESTDBDIR), 0);
ck_assert_int_eq(mkpath(TESTDIR, 0775), 1); ck_assert_int_eq(mkpath(TESTDIR, 0775), 1);
ck_assert_int_eq(direxists(TESTDIR), 1); ck_assert_int_eq(direxists(TESTDIR), 1);
ck_assert_int_eq(direxists(TESTDBDIR), 0); ck_assert_int_eq(direxists(TESTDBDIR), 0);
ck_assert_int_eq(mkpath(TESTDBDIR, 0775), 1); ck_assert_int_eq(mkpath(TESTDBDIR, 0775), 1);
ck_assert_int_eq(direxists(TESTDBDIR), 1); ck_assert_int_eq(direxists(TESTDBDIR), 1);
ck_assert_int_eq(remove_directory(TESTDIR), 1); ck_assert_int_eq(remove_directory(TESTDIR), 1);
ck_assert_int_eq(direxists(TESTDBDIR), 0); ck_assert_int_eq(direxists(TESTDBDIR), 0);
ck_assert_int_eq(mkpath(TESTDBDIR, 0775), 1); ck_assert_int_eq(mkpath(TESTDBDIR, 0775), 1);
ck_assert_int_eq(direxists(TESTDBDIR), 1); ck_assert_int_eq(direxists(TESTDBDIR), 1);
} }
END_TEST END_TEST
START_TEST(preparevnstatdir_with_no_vnstat) START_TEST(preparevnstatdir_with_no_vnstat)
{ {
char testdir[512], testpath[530]; char testdir[512], testpath[530];
defaultcfg();
cfg.updatefileowner = 0; cfg.updatefileowner = 0;
ck_assert_int_eq(remove_directory(TESTDIR), 1); ck_assert_int_eq(remove_directory(TESTDIR), 1);
ck_assert_int_eq(direxists(TESTDIR), 0); ck_assert_int_eq(direxists(TESTDIR), 0);
snprintf(testdir, 512, "%s/here/be/dragons", TESTDIR); snprintf(testdir, 512, "%s/here/be/dragons", TESTDIR);
snprintf(testpath, 530, "%s/or_something.txt", testdir); snprintf(testpath, 530, "%s/or_something.txt", testdir);
preparevnstatdir(testpath, "user", "group"); preparevnstatdir(testpath, "user", "group");
ck_assert_int_eq(direxists(TESTDIR), 0); ck_assert_int_eq(direxists(TESTDIR), 0);
ck_assert_int_eq(direxists(testdir), 0); ck_assert_int_eq(direxists(testdir), 0);
skipping to change at line 108 skipping to change at line 101
snprintf(testpath, 530, "%s/or_something.txt", testdir); snprintf(testpath, 530, "%s/or_something.txt", testdir);
preparevnstatdir(testpath, "user", "group"); preparevnstatdir(testpath, "user", "group");
ck_assert_int_eq(direxists(TESTDIR), 0); ck_assert_int_eq(direxists(TESTDIR), 0);
ck_assert_int_eq(direxists(testdir), 0); ck_assert_int_eq(direxists(testdir), 0);
} }
END_TEST END_TEST
START_TEST(preparevnstatdir_with_vnstat) START_TEST(preparevnstatdir_with_vnstat)
{ {
char testdir[512], testpath[530]; char testdir[512], testpath[530];
defaultcfg();
cfg.updatefileowner = 0; cfg.updatefileowner = 0;
ck_assert_int_eq(remove_directory(TESTDIR), 1); ck_assert_int_eq(remove_directory(TESTDIR), 1);
ck_assert_int_eq(direxists(TESTDIR), 0); ck_assert_int_eq(direxists(TESTDIR), 0);
snprintf(testdir, 512, "%s/here/be/vnstat", TESTDIR); snprintf(testdir, 512, "%s/here/be/vnstat", TESTDIR);
snprintf(testpath, 530, "%s/or_something.txt", testdir); snprintf(testpath, 530, "%s/or_something.txt", testdir);
preparevnstatdir(testpath, "user", "group"); preparevnstatdir(testpath, "user", "group");
ck_assert_int_eq(direxists(TESTDIR), 1); ck_assert_int_eq(direxists(TESTDIR), 1);
ck_assert_int_eq(direxists(testdir), 1); ck_assert_int_eq(direxists(testdir), 1);
 End of changes. 8 change blocks. 
8 lines changed or deleted 0 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)