Distributed File System written in C
1#!/usr/bin/env sh
2
3mylog() {
4 local MSG="$*"
5 local DATE="$(date +"%a %b %d %H:%M:%S %Y")"
6
7 echo -e "$DATE \033[96mINFO\033[0m $MSG"
8}
9
10mylog "Erasing test files"
11echo "rm 500MB.bin another_500MB.bin"
12rm 500MB.bin another_500MB.bin
13
14echo ""
15
16mylog "Testing ls"
17echo "./.build/ls 127.0.0.1 8000"
18./.build/ls 127.0.0.1 8000
19
20echo ""
21mylog "Testing copy from client to server"
22echo ""
23
24mylog "Creating 500MB file with random bytes, called \"500MB.bin\""
25echo "cat /dev/random | head -c500000000 > 500MB.bin"
26cat /dev/random | head -c500000000 > 500MB.bin
27
28mylog "The size of 500MB.bin is:"
29echo "cat 500MB.bin | wc -c"
30cat 500MB.bin | wc -c
31
32echo ""
33
34mylog "Copying file to the server"
35echo "./.build/copy 127.0.0.1 8000 500MB.bin -s /somewhere/in/the/server/500MB.bin"
36./.build/copy 127.0.0.1 8000 500MB.bin -s /somewhere/in/the/server/500MB.bin
37
38echo ""
39
40mylog "Testing ls"
41echo "./.build/ls 127.0.0.1 8000"
42./.build/ls 127.0.0.1 8000
43
44echo ""
45mylog "Testing copy from server to client"
46echo ""
47
48mylog "Copying file from the server to the client"
49echo "./.build/copy 127.0.0.1 8000 -s /somewhere/in/the/server/500MB.bin another_500MB.bin"
50./.build/copy 127.0.0.1 8000 -s /somewhere/in/the/server/500MB.bin another_500MB.bin
51
52echo ""
53
54mylog "Checking if both files are the same"
55diff -s 500MB.bin another_500MB.bin