aboutsummaryrefslogtreecommitdiff
path: root/tests/mv_tests.mk
blob: 3a9012538a8ac570d2b18e67f4fe210b7c20d58f (plain)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# GNU `mv'
GMV = /bin/mv
# BusyBox `mv'
BMV = $(shell pwd)/mv

.PHONY: mv_clean
mv_clean:
	rm -rf mv_tests mv_*.{gnu,bb} mv

.PHONY: mv_tests
mv_tests: mv_clean mv
	@echo;
	@echo "No output from diff means busybox mv is functioning properly.";
	@echo;
	@echo "No such file or directory is good; it means the old file got removed.";
	@echo;
	${BMV} || true;

	@echo;
	mkdir mv_tests;

	@echo;
	cd mv_tests;				\
	 echo A file > afile;			\
	 ls -l afile > ../mv_afile_newname.gnu;	\
	 ${GMV} afile newname;			\
	 ls -l newname >> ../mv_afile_newname.gnu;
	-ls -l mv_tests/afile;

	@echo;
	rm -f mv_tests/{afile,newname};

	@echo;
	cd mv_tests;				\
	 echo A file > afile;			\
	 ls -l afile > ../mv_afile_newname.bb;	\
	 ${BMV} afile newname;			\
	 ls -l newname >> ../mv_afile_newname.bb;
	-ls -l mv_tests/afile;

	@echo;
	diff -u mv_afile_newname.gnu mv_afile_newname.bb;

	@echo;
	rm -f mv_tests/{afile,newname};

	@echo; echo;
	cd mv_tests;				\
	 echo A file > afile;			\
	 ln -s afile symlink;			\
	 ls -l afile symlink > ../mv_symlink_newname.gnu; \
	 ${GMV} symlink newname;		\
	 ls -l afile newname >> ../mv_symlink_newname.gnu;
	-ls -l mv_tests/symlink;

	@echo;
	rm -f mv_tests/{afile,newname};

	@echo;
	cd mv_tests;				\
	 echo A file > afile;			\
	 ln -s afile symlink;			\
	 ls -l afile symlink > ../mv_symlink_newname.bb;\
	 ${BMV} symlink newname;		\
	 ls -l afile newname >> ../mv_symlink_newname.bb;
	-ls -l mv_tests/symlink;

	@echo;
	diff -u mv_symlink_newname.gnu mv_symlink_newname.bb;

	@echo;
	rm -rf mv_tests/*;

	@echo; echo;
	cd mv_tests;				\
	 echo A file > afile;			\
	 ln -s afile symlink;			\
	 mkdir newdir;				\
	 ls -lR > ../mv_file_symlink_dir.gnu;	\
	 ${GMV} symlink afile newdir;		\
	 ls -lR >> ../mv_file_symlink_dir.gnu;
	-ls -l mv_tests/{symlink,afile};

	@echo;
	rm -rf mv_tests/*

	@echo; echo;
	cd mv_tests;				\
	 echo A file > afile;			\
	 ln -s afile symlink;			\
	 mkdir newdir;				\
	 ls -lR > ../mv_file_symlink_dir.bb;	\
	 ${BMV} symlink afile newdir;		\
	 ls -lR >> ../mv_file_symlink_dir.bb;
	-ls -l mv_tests/{symlink,afile};

	@echo;
	diff -u mv_file_symlink_dir.gnu mv_file_symlink_dir.bb;

	@echo;
	rm -rf mv_tests/*;

	@echo; echo;
	cd mv_tests;				\
	 mkdir dir{a,b};			\
	 echo A file > dira/afile;		\
	 echo A file in dirb > dirb/afileindirb; \
	 ln -s dira/afile dira/alinktoafile;	\
	 mkdir dira/subdir1;			\
	 echo Another file > dira/subdir1/anotherfile; \
	 ls -lR . > ../mv_dira_dirb.gnu;	\
	 ${GMV} dira dirb;			\
	 ls -lR . >> ../mv_dira_dirb.gnu;

	# false;
	@echo;
	rm -rf mv_tests/dir{a,b};

	@echo;
	cd mv_tests;				\
	 mkdir dir{a,b};			\
	 echo A file > dira/afile;		\
	 echo A file in dirb > dirb/afileindirb; \
	 ln -s dira/afile dira/alinktoafile;	\
	 mkdir dira/subdir1;			\
	 echo Another file > dira/subdir1/anotherfile; \
	 ls -lR . > ../mv_dira_dirb.bb;		\
	 ${BMV} dira dirb;			\
	 ls -lR . >> ../mv_dira_dirb.bb;

	@echo;
	diff -u mv_dira_dirb.gnu mv_dira_dirb.bb;

	# false;
	@echo;
	rm -rf mv_tests/dir{a,b};