2 # Copyright 2012 Google Inc.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # * Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
14 # * Neither the name of Google Inc. nor the names of its contributors
15 # may be used to endorse or promote products derived from this software
16 # without specific prior written permission.
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 ExamplesDir="__EXAMPLESDIR__"
36 cp "${ExamplesDir}/Makefile" "${ExamplesDir}/${1}.cpp" .
37 make CXX="${Cxx}" "${1}"
39 # Ensure that the binary we just built can find liblutok. This is
40 # needed because the lutok.pc file (which the Makefile used above
41 # queries) does not provide rpaths to the installed library and
42 # therefore the binary may not be able to locate it. Hardcoding the
43 # rpath flags into lutok.pc is non-trivial because we simply don't
44 # have any knowledge about what the correct flag to set an rpath is.
46 # Additionally, setting rpaths is not always the right thing to do.
47 # For example, pkgsrc will automatically change lutok.pc to add the
48 # missing rpath, in which case this is unnecessary. But in the case
49 # of Fedora, adding rpaths goes against the packaging guidelines.
50 if [ -n "${LD_LIBRARY_PATH}" ]; then
51 export LD_LIBRARY_PATH="${LibDir}:${LD_LIBRARY_PATH}"
53 export LD_LIBRARY_PATH="${LibDir}"
59 local name="${1}"; shift
61 atf_test_case "${name}"
62 eval "${name}_head() { \
63 atf_set 'require.files' '${ExamplesDir}/${name}.cpp'; \
64 atf_set 'require.progs' 'make pkg-config'; \
66 eval "${name}_body() { \
67 make_example '${name}'; \
73 example_test_case bindings
75 atf_check -s exit:0 -o inline:'120\n' ./bindings 5
76 atf_check -s exit:1 -e match:'Argument.*must be an integer' ./bindings foo
77 atf_check -s exit:1 -e match:'Argument.*must be positive' ./bindings -5
81 example_test_case hello
83 atf_check -s exit:0 -o inline:'Hello, world!\n' ./hello
87 example_test_case interpreter
88 interpreter_validate() {
91 print("From the interpreter: " .. (test_variable - 345))
94 atf_check -s exit:0 -o match:"From the interpreter: 12000" \
95 -x "./interpreter <script.lua"
99 example_test_case raii
102 String in field foo: hello
103 String in field bar: 123
104 String in field baz: bye
106 atf_check -s exit:0 -o file:expout ./raii
110 atf_init_test_cases() {
111 atf_add_test_case bindings
112 atf_add_test_case hello
113 atf_add_test_case interpreter
114 atf_add_test_case raii