-
Notifications
You must be signed in to change notification settings - Fork 64
/
test.sh
executable file
·95 lines (78 loc) · 3.32 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
##############################################################################
# Description:
#
# A test to check if dcp1 will copy many directories to a single file.
#
# Expected behavior:
#
# An error code should be displayed if this action is attempted.
#
# Reminder:
#
# Lines that echo to the terminal will only be available if DEBUG is enabled
# in the test runner (test_all.sh).
##############################################################################
# Turn on verbose output
#set -x
# Print out the basic paths we'll be using.
echo "Using dcp1 binary at: $DCP_TEST_BIN"
echo "Using tmp directory at: $DCP_TEST_TMP"
##############################################################################
# Generate the paths for:
# * A file with zero length.
# * A file which contains random data.
# * A file which doesn't exist.
# * Four directories.
PATH_A_EMPTY="$DCP_TEST_TMP/dcp1_test_many_dir_to_single_file.$RANDOM.tmp"
PATH_B_RANDOM="$DCP_TEST_TMP/dcp1_test_many_dir_to_single_file.$RANDOM.tmp"
PATH_C_NOEXIST="$DCP_TEST_TMP/dcp1_test_many_dir_to_single_file.$RANDOM.tmp"
PATH_D_DIRECTORY="$DCP_TEST_TMP/dcp1_test_many_dir_to_single_file.$RANDOM.tmp"
PATH_E_DIRECTORY="$DCP_TEST_TMP/dcp1_test_many_dir_to_single_file.$RANDOM.tmp"
PATH_F_DIRECTORY="$DCP_TEST_TMP/dcp1_test_many_dir_to_single_file.$RANDOM.tmp"
PATH_G_DIRECTORY="$DCP_TEST_TMP/dcp1_test_many_dir_to_single_file.$RANDOM.tmp"
# Print out the generated paths to make debugging easier.
echo "A_EMPTY path at: $PATH_A_EMPTY"
echo "B_RANDOM path at: $PATH_B_RANDOM"
echo "C_NOEXIST path at: $PATH_C_NOEXIST"
echo "D_DIRECTORY path at: $PATH_D_DIRECTORY"
echo "E_DIRECTORY path at: $PATH_E_DIRECTORY"
echo "F_DIRECTORY path at: $PATH_F_DIRECTORY"
echo "G_DIRECTORY path at: $PATH_G_DIRECTORY"
# Create an empty file.
touch $PATH_A_EMPTY
# Create the random file.
dd if=/dev/urandom of=$PATH_B_RANDOM bs=2M count=4
# Create the directories.
mkdir $PATH_D_DIRECTORY
mkdir $PATH_E_DIRECTORY
mkdir $PATH_F_DIRECTORY
mkdir $PATH_G_DIRECTORY
##############################################################################
# Test copying several directories into an empty file. This should result in
# an error.
mpirun -n 3 $DCP_TEST_BIN $PATH_D_DIRECTORY $PATH_E_DIRECTORY $PATH_F_DIRECTORY $PATH_A_EMPTY
if [[ $? -eq 0 ]]; then
echo "Unexpected success when copying several directories to an empty file. (D,E,F -> A)."
exit 1;
fi
##############################################################################
# Test copying several directories into a random file. This should result in
# an error.
mpirun -n 3 $DCP_TEST_BIN $PATH_D_DIRECTORY $PATH_E_DIRECTORY $PATH_F_DIRECTORY $PATH_B_RANDOM
if [[ $? -eq 0 ]]; then
echo "Unexpected success when copying several directories to a random file. (D,E,F -> B)."
exit 1;
fi
##############################################################################
# Test copying several directories into a no-exist file. This should result in
# an error.
mpirun -n 3 $DCP_TEST_BIN $PATH_D_DIRECTORY $PATH_E_DIRECTORY $PATH_F_DIRECTORY $PATH_C_NOEXIST
if [[ $? -eq 0 ]]; then
echo "Unexpected success when copying several directories to a no-exist file. (D,E,F -> C)."
exit 1;
fi
##############################################################################
# Since we didn't find any problems, exit with success.
exit 0
# EOF