commit
a1b6298a7f
@ -1,10 +1,11 @@
|
||||
set(TARGET_NAME run_tests)
|
||||
|
||||
set(TARGET_LAYER0 test_layer0)
|
||||
set(DIR_PLACE /dev/vdb)
|
||||
|
||||
# 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
|
||||
|
||||
)
|
||||
# add test to activate ctest -VV
|
||||
add_test(NAME ${TARGET_LAYER0} COMMAND sudo ./${TARGET_LAYER0} ${DIR_PLACE})
|
34
test/layer0.cpp
Normal file
34
test/layer0.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include "rawdisk.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
char *d = NULL;
|
||||
if(argc < 2){
|
||||
d = strdup("/dev/vdc");
|
||||
}else{
|
||||
d = argv[1];
|
||||
}
|
||||
|
||||
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