add layer0 test
This commit is contained in:
parent
2316b93ff0
commit
e38810caf3
@ -1,10 +1,11 @@
|
|||||||
set(TARGET_NAME run_tests)
|
set(TARGET_LAYER0 test_layer0)
|
||||||
|
|
||||||
|
|
||||||
# add test sources here ...
|
# add test sources here ...
|
||||||
add_executable(${TARGET_NAME}
|
add_executable(${TARGET_LAYER0}
|
||||||
|
# add need lib and source code here
|
||||||
|
layer0.cpp
|
||||||
|
)
|
||||||
|
|
||||||
../lib/fischl.cpp
|
# add test to activate ctest -VV
|
||||||
testfischl.cpp
|
add_test(NAME ${TARGET_LAYER0} COMMAND sudo ./${TARGET_LAYER0})
|
||||||
|
|
||||||
)
|
|
28
test/layer0.cpp
Normal file
28
test/layer0.cpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#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;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user