File: xctest

package info (click to toggle)
xclip 0.13-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 344 kB
  • sloc: ansic: 1,282; sh: 267; makefile: 75
file content (96 lines) | stat: -rwxr-xr-x 2,572 bytes parent folder | download | duplicates (4)
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
#!/bin/sh
#
#  
# 
#  xctest - shell script to test xclip
#  Copyright (C) 2001 Kim Saunders
# 
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
# 
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

delay=1 # seconds to wait before running xclip -o

# test to make sure ./xclip exists
if [ ! -f xclip ];
then
	echo "Error: xclip doesn't exist in the current directory."
	exit
fi

checker=""

for param in $@;
do
	case $param in
		--valgrind) checker="valgrind --num-callers=8";;
	esac
done

# test xclip on different amounts of data to bring out any errors
for lines in 2 16 128 1024 8192
do
	# temp file names (in and out)
	tempi=`mktemp` || exit 1
	tempo=`mktemp` || exit 1

	linec=0	# current line of file in while loop

	# append lines two at a time to input temp file
	while [ $linec -lt `expr $lines / 2` ]
	do
		echo -n -e "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890\n" >> $tempi
		echo -n -e "abcdefghijklmnopqrstuvwzyz!@#$%^&*()\n" >> $tempi
		linec=$(($linec+1))
	done

	# test piping the file to xclip, using all selections
	echo Piping a $lines line file to xclip
	for sel in primary secondary clipboard buffer
	do
		echo "  Using the $sel selection"
		cat $tempi | $checker ./xclip -sel $sel -i
		sleep $delay
		$checker ./xclip -sel $sel -o > $tempo
		diff $tempi $tempo
	done
	echo

	# test xclip reading the file
	echo Reading a $lines line file with xclip
	for sel in primary secondary clipboard buffer
	do
		echo "  Using the $sel selection"
		$checker ./xclip -sel $sel -i $tempi
		sleep $delay
		$checker ./xclip -sel $sel -o > $tempo
		diff $tempi $tempo
	done
	echo
	
	# test xclip filtering a file
	echo Filtering a $lines line file through xclip
	for sel in primary secondary clipboard buffer
	do
		echo "  Using the $sel selection"
		$checker ./xclip -sel $sel -f < $tempi > $tempo
		sleep $delay
		diff $tempi $tempo
	done
	echo

	# quietly remove temp files
	rm $tempi $tempo 2> /dev/null
done

# Kill any remain xclip processes
killall xclip