diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fd0a947..1b77761 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,10 +1,11 @@ -set(TARGET_NAME run_tests) +set(TARGET_LAYER0 test_layer0) # add test sources here ... -add_executable(${TARGET_NAME} +add_executable(${TARGET_LAYER0} + # add need lib and source code here + layer0.cpp +) - ../lib/fischl.cpp - testfischl.cpp - -) \ No newline at end of file +# add test to activate ctest -VV +add_test(NAME ${TARGET_LAYER0} COMMAND sudo ./${TARGET_LAYER0}) \ No newline at end of file diff --git a/test/layer0.cpp b/test/layer0.cpp new file mode 100644 index 0000000..4d95e8d --- /dev/null +++ b/test/layer0.cpp @@ -0,0 +1,28 @@ +#include +#include +#include +#include "rawdisk.h" + +int main() { + char *d = strdup("/dev/vdb"); + RawDisk *H = new RawDisk(d); + + char *buf = "iloveosdfjlseirfnerig"; + char readBuffer[512] = {0}; // Initialize to zeros + + //printf("dir %s, numSectors %lld, diskSize %lld \n", H->dir, H->numSectors, H->diskSize); + + //use number to substitute H->getnumSector(), getnumSectors() are not yest implemented + for(off_t i = 0; i < 10; i++) { + H->rawdisk_write(i, buf); + } + //use number to substitute H->getnumSector(), getnumSectors() are not yest implemented + for(off_t i = 0; i < 10; i++) { + H->rawdisk_read(i, readBuffer); + assert(strncmp(readBuffer, buf, strlen(buf)) == 0); + } + + delete H; // Delete the RawDisk object + + return 0; +}