File tree Expand file tree Collapse file tree 1 file changed +71
-0
lines changed
itacademy/LinuxEssBash/virtual_lab/test_scripts Expand file tree Collapse file tree 1 file changed +71
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # this is initial version to test hometask script
4+ # place this file to directory with script
5+ # run: bash topten_test.sh ./topten.sh
6+
7+ script_name=${1:- tt.sh}
8+
9+ is_exit_error (){
10+ [ $1 != 0 ] && echo pass
11+ }
12+
13+ is_exit_success (){
14+ [ $1 == 0 ] && echo pass
15+ }
16+
17+ # task create directory with files
18+ # files with sizes from 1M, 2M, 3M to 10M
19+ # names file_size_1M
20+
21+ test_dir_big_files (){
22+ test_dir_name=${1:- test_dir}
23+ [ -d " $test_dir_name " ] || mkdir " $test_dir_name "
24+ for size in {1..10}
25+ do
26+ dd if=/dev/urandom of=./" ${test_dir_name} " /file_size_${size} M bs=1M count=$size 1> /dev/null 2>&1
27+ done
28+ echo bash " $script_name " " $test_dir_name "
29+ bash " $script_name " " $test_dir_name "
30+ }
31+
32+ test_help (){
33+ echo bash " $script_name " -h
34+ bash " $script_name " -h
35+ is_exit_success $?
36+ }
37+
38+ test_two_args (){
39+ echo bash " $script_name " argument1 argument2
40+ bash " $script_name " argument1 argument2
41+ is_exit_error $?
42+ }
43+
44+ test_noargs (){
45+ echo bash " $script_name "
46+ bash " $script_name "
47+ is_exit_error $?
48+ }
49+
50+ test_non_exised_file (){
51+ echo bash " $script_name " /abcd
52+ bash " $script_name " /abcd
53+ is_exit_error $?
54+ }
55+
56+ test_non_dir_file (){
57+ echo bash " $script_name " /etc/passwd
58+ bash " $script_name " /etc/passwd
59+ is_exit_error $?
60+ }
61+
62+ test_spaces (){
63+ test_dir_big_files " dir with spaces"
64+ }
65+
66+ test_dir_big_files
67+ test_spaces
68+ test_help
69+ test_two_args
70+ test_non_exised_file
71+ test_non_dir_file
You can’t perform that action at this time.
0 commit comments