#include #include #include #include "unity/unity.h" #include "fuse.h" #include "fuseactions.h" FileSystem* fakefs; fuseArgStruct dummyFuse; int argc = 5; char* argv[5]; void setUp(void) { FuseStructInit(&dummyFuse); argv[0] = "bin/fuse.out"; argv[1] = "-l"; argv[2] = "test/files/test1.txt"; argv[3] = "-f"; argv[4] = "test/fakefs.test"; } void tearDown(void) { ; } void Test_FuseGetArgs_Should_SetDummyArgs(void) { GetArguments(argc, argv, &dummyFuse); TEST_ASSERT_EQUAL(1, dummyFuse.list); argv[1] = "-a"; GetArguments(argc, argv, &dummyFuse); TEST_ASSERT_EQUAL(1, dummyFuse.add); argv[1] = "-r"; GetArguments(argc, argv, &dummyFuse); TEST_ASSERT_EQUAL(1, dummyFuse.remove); argv[1] = "-e"; GetArguments(argc, argv, &dummyFuse); TEST_ASSERT_EQUAL(1, dummyFuse.extract); } void Test_FindEmptyBitPosition_Should_ReturnPosition(void) { TEST_ASSERT_EQUAL(3, FindEmptyBitPosition(7)); TEST_ASSERT_EQUAL(1, FindEmptyBitPosition(29)); TEST_ASSERT_EQUAL(5, FindEmptyBitPosition(95)); TEST_ASSERT_EQUAL(31, FindEmptyBitPosition(2147483647)); TEST_ASSERT_EQUAL(-1, FindEmptyBitPosition(4294967295)); } void Test_FileSystem_Should_SuccessfullyOpen(void) { remove(argv[4]); GetArguments(argc, argv, &dummyFuse); OpenFS(&dummyFuse, argv[0]); fakefs = SetupFS(&dummyFuse); } void Test_FileSystem_Should_AddFile(void) { argv[1] = "-a"; GetArguments(argc, argv, &dummyFuse); RunFuse(fakefs, &dummyFuse); TEST_ASSERT_EQUAL(1, fakefs->inodes[1].isValid); } int main(void) { UNITY_BEGIN(); RUN_TEST(Test_FuseGetArgs_Should_SetDummyArgs); RUN_TEST(Test_FindEmptyBitPosition_Should_ReturnPosition); RUN_TEST(Test_FileSystem_Should_SuccessfullyOpen); RUN_TEST(Test_FileSystem_Should_AddFile); return UNITY_END(); }