File: test_handle_read.sh

package info (click to toggle)
libbfio 20140105-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 8,800 kB
  • ctags: 2,962
  • sloc: ansic: 95,778; sh: 11,974; makefile: 714; sed: 16
file content (89 lines) | stat: -rwxr-xr-x 1,899 bytes parent folder | download
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
#!/bin/bash
#
# Cross-platform C file functions library handle read offset testing script
#
# Copyright (c) 2009-2014, Joachim Metz <joachim.metz@gmail.com>
#
# Refer to AUTHORS for acknowledgements.
#
# This software is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This software 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 Lesser General Public License
# along with this software.  If not, see <http://www.gnu.org/licenses/>.
#

EXIT_SUCCESS=0;
EXIT_FAILURE=1;
EXIT_IGNORE=77;

test_handle_read()
{ 
	rm -rf tmp;
	mkdir tmp;

	echo "Testing read offset of input:" $*;

	${TEST_RUNNER} ./${BFIO_TEST_HANDLE_READ} $*;

	RESULT=$?;

	rm -rf tmp;

	echo "";

	return ${RESULT};
}

BFIO_TEST_HANDLE_READ="bfio_test_handle_read";

if ! test -x ${BFIO_TEST_HANDLE_READ};
then
	BFIO_TEST_HANDLE_READ="bfio_test_handle_read.exe";
fi

if ! test -x ${BFIO_TEST_HANDLE_READ};
then
	echo "Missing executable: ${BFIO_TEST_HANDLE_READ}";

	exit ${EXIT_FAILURE};
fi

TEST_RUNNER="tests/test_runner.sh";

if ! test -x ${TEST_RUNNER};
then
        TEST_RUNNER="./test_runner.sh";
fi

if ! test -x ${TEST_RUNNER};
then
        echo "Missing test runner: ${TEST_RUNNER}";

        exit ${EXIT_FAILURE};
fi

if ! test -d input;
then
	echo "No input directory found, to test read create input directory and place test files in directory.";

	exit ${EXIT_IGNORE};
fi

for FILENAME in input/*;
do
	if ! test_handle_read ${FILENAME};
	then
		exit ${EXIT_FAILURE};
	fi
done

exit ${EXIT_SUCCESS};