summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/test-cow-fuse.yml (renamed from .github/workflows/elefant.yml)78
-rw-r--r--src/cowtest/main.c73
2 files changed, 94 insertions, 57 deletions
diff --git a/.github/workflows/elefant.yml b/.github/workflows/test-cow-fuse.yml
index db44a63..27d7558 100644
--- a/.github/workflows/elefant.yml
+++ b/.github/workflows/test-cow-fuse.yml
@@ -28,11 +28,15 @@ jobs:
-D CMAKE_BUILD_TYPE=${{ matrix.config.build-type }} \
-D DNBD3_KERNEL_MODULE=OFF \
-D DNBD3_BENCHMARK=OFF \
- -D DNBD3_SERVER_FUSE=OFF \
- -D DNBD3_SERVER=ON \
- -D DNBD3_SERVER_FUSE=ON \
+ -D DNBD3_CLIENT_FUSE=ON \
-D DNBD3_CLIENT_FUSE_COW_TEST=ON \
- -D DNBD3_RELEASE_HARDEN=OFF
+ -D DNBD3_SERVER=ON \
+ -D DNBD3_SERVER_FUSE=OFF \
+ -D DNBD3_SERVER_AFL=OFF \
+ -D DNBD3_SERVER_DEBUG_LOCKS=OFF \
+ -D DNBD3_SERVER_DEBUG_THREADS=OFF \
+ -D DNBD3_RELEASE_HARDEN=OFF \
+ -D DNBD3_PACKAGE_DOCKER=OFF
- name: Build dnbd3 artifacts
working-directory: ${{ github.workspace }}/build
@@ -42,18 +46,18 @@ jobs:
run: git clone --depth 1 --branch "master" "https://github.com/z0Kng/cow_merger_service.git" "../cow_server"
- name: Build cow_merger_service
working-directory: ${{ github.workspace }}/../cow_server/cow_merger_service
- run: dotnet build cow_merger_service.csproj --runtime linux-x64
+ run: dotnet publish -c Release -o publish -p:PublishReadyToRun=true -p:PublishSingleFile=true -p:PublishReadyToRunShowWarnings=true --self-contained true --runtime linux-x64
- name: Setup cow_merger_service
working-directory: ${{ github.workspace }}/../cow_server/
run: |
mkdir /home/runner/work/WorkingDirectory
mkdir /home/runner/work/OriginalImageDirectory
mkdir /home/runner/work/Output
- sed -i 's/^ "WorkingDirectory":.*/ "WorkingDirectory": "\/home\/runner\/work\/WorkingDirectory",/g' cow_merger_service/bin/Debug/net5.0/linux-x64/appsettings.json
- sed -i 's/^ "OriginalImageDirectory":.*/ "OriginalImageDirectory": "\/home\/runner\/work\/OriginalImageDirectory",/g' cow_merger_service/bin/Debug/net5.0/linux-x64/appsettings.json
- sed -i 's/^ "DestinationDirectory":.*/ "DestinationDirectory": "\/home\/runner\/work\/Output",/g' cow_merger_service/bin/Debug/net5.0/linux-x64/appsettings.json
- while read line; do echo $line; done < cow_merger_service/bin/Debug/net5.0/linux-x64/appsettings.json
- cd cow_merger_service/bin/Debug/net5.0/linux-x64/
+ sed -i 's/^ "WorkingDirectory":.*/ "WorkingDirectory": "\/home\/runner\/work\/WorkingDirectory",/g' cow_merger_service/publish/appsettings.json
+ sed -i 's/^ "OriginalImageDirectory":.*/ "OriginalImageDirectory": "\/home\/runner\/work\/OriginalImageDirectory",/g' cow_merger_service/publish/appsettings.json
+ sed -i 's/^ "DestinationDirectory":.*/ "DestinationDirectory": "\/home\/runner\/work\/Output",/g' cow_merger_service/publish/appsettings.json
+ while read line; do echo $line; done < cow_merger_service/publish/appsettings.json
+ cd cow_merger_service/publish/
./cow_merger_service 2>&1 > log.out &
- name: Generate test file
working-directory: ${{ github.workspace }}/build/src/cowtest
@@ -72,7 +76,7 @@ jobs:
run: |
mkdir /home/runner/work/mount
mkdir /home/runner/work/tmp
- ./fuse/dnbd3-fuse "/home/runner/work/mount" -f -h localhost -i test -c "/home/runner/work/tmp" -C localhost:5000 -y -x 2>&1 > /home/runner/work/tmp/log1.out &
+ ./fuse/dnbd3-fuse "/home/runner/work/mount" -f -h localhost -i test -c "/home/runner/work/tmp" -C localhost:5000 -y -x 2>&1 > /home/runner/work/tmp/standardLog1.out &
PID=$!
sleep 5
echo PID: $PID
@@ -81,7 +85,7 @@ jobs:
sudo umount /home/runner/work/mount
wait $PID
echo unmounted
- ./fuse/dnbd3-fuse "/home/runner/work/mount" -f -h localhost -i test -L "/home/runner/work/tmp" -C localhost:5000 -m -y -x 2>&1 > /home/runner/work/tmp/log2.out &
+ ./fuse/dnbd3-fuse "/home/runner/work/mount" -f -h localhost -i test -L "/home/runner/work/tmp" -C localhost:5000 -m -y -x 2>&1 > /home/runner/work/tmp/standardLog2.out &
PID=$!
sleep 5
echo PID: $PID
@@ -93,22 +97,62 @@ jobs:
sleep 30
echo Output: $(ls /home/runner/work/Output)
./cowtest/dnbd3-fuse-cow-test -v /home/runner/work/Output/test.r2
+ - name: Run random test
+ working-directory: ${{ github.workspace }}/build/src
+ run: |
+ cp /home/runner/work/OriginalImageDirectory/test.r1 /home/runner/work/
+ ./fuse/dnbd3-fuse "/home/runner/work/mount" -f -h localhost -i test -c "/home/runner/work/tmp" -C localhost:5000 -y -x 2>&1 > /home/runner/work/tmp/randomLog1.out &
+ PIDFUSE=$!
+ sleep 5
+ echo PIDFUSE : $PIDFUSE
+ ./cowtest/dnbd3-fuse-cow-test --randomTest "/home/runner/work/mount/img" "/home/runner/work/test.r1" 2>&1 > /home/runner/work/tmp/randomTestLog.out &
+ PIDTEST=$!
+ sleep 60
+ echo "stopping test"
+ kill -INT $PIDTEST
+ wait $PIDTEST
+ echo "testStopped"
+ echo unmounting: $PIDFUSE
+ sudo umount /home/runner/work/mount
+ echo unmounted
+ wait $PIDFUSE
+ ./fuse/dnbd3-fuse "/home/runner/work/mount" -f -h localhost -i test -L "/home/runner/work/tmp" -C localhost:5000 -m -y -x 2>&1 > /home/runner/work/tmp/randomLog2.out &
+ PIDFUSE=$!
+ sleep 5
+ echo PIDFUSE : $PIDFUSE
+ ./cowtest/dnbd3-fuse-cow-test --compare "/home/runner/work/mount/img" "/home/runner/work/test.r1"
+ echo unmounting: $PIDFUSE
+ sudo umount /home/runner/work/mount
+ echo unmounted
+ wait $PIDFUSE
+ sleep 30
+ echo Output: $(ls /home/runner/work/Output)
+ ./cowtest/dnbd3-fuse-cow-test --compare "/home/runner/work/Output/test.r3" "/home/runner/work/test.r1"
- name: Print logs
if: always()
run: |
echo "====fuse-client status.txt===="
while read line; do echo $line; done < /home/runner/work/tmp/status.txt
echo
- echo "====fuse-client log1.out===="
- while read line; do echo $line; done < /home/runner/work/tmp/log1.out
+ echo "====fuse-client standardLog1.out===="
+ while read line; do echo $line; done < /home/runner/work/tmp/standardLog1.out
+ echo
+ echo "====fuse-client standardLog2.out===="
+ while read line; do echo $line; done < /home/runner/work/tmp/standardLog2.out
+ echo
+ echo "====fuse-client randomLog1.out===="
+ while read line; do echo $line; done < /home/runner/work/tmp/randomLog1.out
+ echo
+ echo "====fuse-client randomLog2.out===="
+ while read line; do echo $line; done < /home/runner/work/tmp/randomLog2.out
echo
- echo "====fuse-client log2.out===="
- while read line; do echo $line; done < /home/runner/work/tmp/log2.out
+ echo "====fuse-client randomTestLog.out===="
+ while read line; do echo $line; done < /home/runner/work/tmp/randomTestLog.out
echo
echo "====dnbd3-server===="
while read line; do echo $line; done < ${{ github.workspace }}/build/src/server/dnbd3.log
echo
echo "====cow_merger_service===="
- while read line; do echo $line; done < ${{ github.workspace }}/../cow_server/cow_merger_service/bin/Debug/net5.0/linux-x64/log.out
+ while read line; do echo $line; done < ${{ github.workspace }}/../cow_server/cow_merger_service/publish/log.out
diff --git a/src/cowtest/main.c b/src/cowtest/main.c
index 9b67cda..9c19be1 100644
--- a/src/cowtest/main.c
+++ b/src/cowtest/main.c
@@ -14,6 +14,7 @@
#include <time.h>
#include <pthread.h>
#include <getopt.h>
+#include <signal.h>
typedef bool ( *func_ptr )();
typedef struct verify_test
@@ -30,13 +31,7 @@ typedef struct special_test
} special_test_t;
-typedef struct random_write_args
-{
- char *mountedImage;
- char *normalImage;
- float minSizePercent;
- float maxSizePercent;
-} random_write_args_t;
+
const size_t l2Size = 1024;
const size_t bitfieldByteSize = 40;
@@ -832,9 +827,10 @@ bool specialTwoFilesTest( char *mountedImagePath, char *normalImagePath )
{782128012, 0},
{945591351, 0},
{956534784, 344064},
- { 966615040, 397312 }, { 906517288, 0 },
+ {966615040, 397312 },
+ {906517288, 0 },
{2062985199, 0},
- { 966663420, 1097920 },
+ {966663420, 1097920 },
{969617408, 327680},
{957513728, 1105920},
{964941207, 1183680},
@@ -856,12 +852,9 @@ bool specialTwoFilesTest( char *mountedImagePath, char *normalImagePath )
return compareTwoFiles( mountedImagePath, normalImagePath, fhm, fhn );
}
-void *randomWriteTest( void *args )
+bool randomWriteTest( char *mountedImagePath, char *normalImagePath, float minSizePercent, float maxSizePercent)
{
- char *mountedImagePath = ( (random_write_args_t *)args )->mountedImage;
- char *normalImagePath = ( (random_write_args_t *)args )->normalImage;
- float minSizePercent = ( (random_write_args_t *)args )->minSizePercent;
- float maxSizePercent = ( (random_write_args_t *)args )->maxSizePercent;
+
int fhm;
int fhn;
@@ -930,9 +923,9 @@ void *randomWriteTest( void *args )
generateRandomData( fhr, buf, size );
printf( "write offset: %zu size: %zu\n", offset, size );
if ( !writeSizeTested( fhm, buf, size, offset, "failed to write on mounted image" ) )
- return (void*) false;
+ return false;
if ( !writeSizeTested( fhn, buf, size, offset, "failed to write on normal image" ) )
- return (void*) false;
+ return false;
}
}
@@ -940,13 +933,16 @@ void *randomWriteTest( void *args )
printf( "comparing both files: \n\n" );
compareTwoFiles( mountedImagePath, normalImagePath, fhm, fhn );
- return (void*) true;
+ return true;
}
+void cancled_handler(int s){
+ randomTestLoop = false;
+}
bool startRandomWriteTest( char *mountedImagePath, char *normalImagePath, float minSizePercent, float maxSizePercent )
{
- // start Thread
+
if ( minSizePercent < 0 || maxSizePercent < minSizePercent || maxSizePercent < 0.1 ) {
@@ -955,32 +951,29 @@ bool startRandomWriteTest( char *mountedImagePath, char *normalImagePath, float
maxSizePercent = RND_DEFAULT_MAX_SIZE_PERCENT;
}
printf( "minSizePercent: %.1f%% maxSizePercent: %.1f%%\n", minSizePercent * 100, maxSizePercent * 100 );
- pthread_t tid;
- random_write_args_t *args = malloc( sizeof( random_write_args_t ) );
-
- args->mountedImage = mountedImagePath;
- args->normalImage = normalImagePath;
- args->minSizePercent = minSizePercent;
- args->maxSizePercent = maxSizePercent;
-
- bool *result;
- pthread_create( &tid, NULL, &randomWriteTest, args );
- // wait for key
- getchar();
- randomTestLoop = false;
- pthread_join( tid, (void*) &result );
- free( args );
- return result;
+ struct sigaction sigIntHandler;
+ sigIntHandler.sa_handler = cancled_handler;
+ sigemptyset(&sigIntHandler.sa_mask);
+ sigIntHandler.sa_flags = SA_SIGINFO;
+ sigaction(SIGINT, &sigIntHandler, NULL);
+
+ return randomWriteTest(mountedImagePath, normalImagePath, minSizePercent, maxSizePercent);
}
static const char *optString = "d:c:t:v:r:x:y:z:w:h:";
-static const struct option longOpts[] = { { "delay", required_argument, NULL, 'd' },
- { "testFile", optional_argument, NULL, 'c' }, { "test", required_argument, NULL, 't' },
- { "verify", required_argument, NULL, 'v' }, { "specialTwoFiles", required_argument, NULL, 'w' },
- { "randomTest", required_argument, NULL, 'r' }, { "compare", required_argument, NULL, 'x' },
- { "minSizePercent", required_argument, NULL, 'y' }, { "maxSizePercent", required_argument, NULL, 'z' },
- { "help", required_argument, NULL, 'h' }, { 0, 0, 0, 0 } };
+static const struct option longOpts[] = {
+ { "delay", required_argument, NULL, 'd' },
+ { "testFile", optional_argument, NULL, 'c' },
+ { "test", required_argument, NULL, 't' },
+ { "verify", required_argument, NULL, 'v' },
+ { "specialTwoFiles", required_argument, NULL, 'w' },
+ { "randomTest", required_argument, NULL, 'r' },
+ { "compare", required_argument, NULL, 'x' },
+ { "minSizePercent", required_argument, NULL, 'y' },
+ { "maxSizePercent", required_argument, NULL, 'z' },
+ { "help", required_argument, NULL, 'h' },
+ { 0, 0, 0, 0 } };
void printUsageStandardTest()