5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 __revision__
= "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
28 Verifies correct use of a live rpcgen command.
33 _python_
= TestSCons
._python
_
36 test
= TestSCons
.TestSCons()
38 rpcgen
= test
.where_is('rpcgen')
40 test
.skip_test('Can not find installed "rpcgen", skipping test.\n')
42 test
.subdir('do_rpcgen')
44 test
.write('SConstruct', """\
46 env = Environment(ENV=os.environ)
47 if env['PLATFORM'] == 'darwin':
48 # The generated rpcif_clnt.c file uses memset() without the necessary
49 # #include <stdlib.h> to get the declarations right. Suppress the
50 # warnings so the test passes.
51 env.Append(CCFLAGS=['-w'])
53 # on some Linux systems, RPC support has moved to libtirpc. Check for that.
55 env.Append(CPPPATH=['/usr/include/tirpc'])
56 if conf.CheckLibWithHeader('tirpc', 'rpc/rpc.h', 'c'):
57 env.Append(LIBS=['tirpc'])
60 env.Program('rpcclnt', ['rpcclnt.c', 'do_rpcgen/rpcif_clnt.c'])
61 env.RPCGenHeader('do_rpcgen/rpcif')
62 env.RPCGenClient('do_rpcgen/rpcif')
63 env.RPCGenService('do_rpcgen/rpcif')
64 env.RPCGenXDR('do_rpcgen/rpcif')
67 test
.write(['do_rpcgen', 'rpcif.x'], """\
70 version RPCTEST_IF_VERSION
72 int START(unsigned long) = 1;
73 int STOP(unsigned long) = 2;
74 int STATUS(unsigned long) = 3;
76 } = 0xfeedf00d; /* portmap program ID */
79 # Following test tries to make sure it can compile and link, but when
80 # it's run it doesn't actually invoke any rpc operations because that
81 # would have significant dependencies on network configuration,
82 # portmapper, etc. that aren't necessarily appropriate for an scons
85 test
.write('rpcclnt.c', """\
87 #include <rpc/pmap_clnt.h>
88 #include "do_rpcgen/rpcif.h"
90 int main(int argc, char **args) {
91 const char* const SERVER = "localhost";
94 unsigned long arg = 0;
96 cl = clnt_create( SERVER, RPCTEST_IF, RPCTEST_IF_VERSION, "udp" );
97 if (cl == 0 ) { return 1; }
98 rslt = start_1(&arg, cl);
99 if (*rslt == 0) { clnt_perror( cl, SERVER ); return 1; }
110 test
.run(program
=test
.workpath('rpcclnt'+_exe
))
112 test
.fail_test(not test
.stdout() in ["Hello!\n", "Hello!\r\n"])
120 # indent-tabs-mode:nil
122 # vim: set expandtab tabstop=4 shiftwidth=4: