4 NAME =
'test-pkgconfig' 7 #include <sys/types.h> /* iob.h need this */ 8 #include "hrpsys/io/iob.h" 9 int main (int argc, char** argv) 16 import unittest, os, sys
17 from subprocess
import call, check_output, Popen, PIPE, STDOUT
24 hrpsys_path = check_output([
'rospack',
'find',
'hrpsys']).rstrip()
25 openhrp3_path = check_output([
'rospack',
'find',
'openhrp3']).rstrip()
26 if os.path.exists(os.path.join(hrpsys_path,
"bin")) :
27 self.
PKG_CONFIG_PATH=
'PKG_CONFIG_PATH=%s/lib/pkgconfig:%s/lib/pkgconfig:$PKG_CONFIG_PATH'%(hrpsys_path, openhrp3_path)
30 return check_output(
"%s pkg-config hrpsys-base --variable=%s"%(self.
PKG_CONFIG_PATH, var), shell=
True).rstrip()
35 pkg_path = os.path.join(pkg_dname, fname)
36 pkg_ret = os.path.exists(pkg_path)
37 self.assertTrue(pkg_ret,
"pkg-config hrpsys --variable=%s`/%s (%s) returns %r"%(pkg_var, fname, pkg_path, pkg_ret))
41 pkg_dname = check_output([
'rospack',
'find',
'hrpsys']).rstrip()
42 pkg_path = os.path.join(pkg_dname, fname)
43 pkg_ret = os.path.exists(pkg_path)
44 self.assertTrue(pkg_ret,
"`rospack find hrpsys`(%s) returns %r"%(pkg_path, pkg_ret))
59 cmd =
"%s pkg-config hrpsys-base --cflags --libs"%(self.
PKG_CONFIG_PATH)
60 print "`"+cmd+
"` =",check_output(cmd, shell=
True, stderr=STDOUT)
61 ret = call(
"gcc -o hrpsys-sample-pkg-config /tmp/%d-hrpsys-sample.cpp `%s` -lhrpIo"%(PID,cmd), shell=
True)
62 self.assertTrue(ret==0)
65 cmd =
"%s pkg-config hrpsys-base --variable=idldir"%(self.
PKG_CONFIG_PATH)
66 print "`"+cmd+
"`/RobotHardwareService.idl = ",os.path.join(check_output(cmd, shell=
True, stderr=STDOUT).rstrip(),
"RobotHardwareService.idl")
67 self.assertTrue(os.path.exists(os.path.join(check_output(cmd, shell=
True).rstrip(),
"RobotHardwareService.idl")))
70 if __name__ ==
'__main__':
74 f = open(
"/tmp/%d-hrpsys-sample.cpp"%(PID),
'w')
77 rostest.run(PKG, NAME, TestHrpsysPkgconfig, sys.argv)
def check_if_file_exists(self, var, fname)
def test_files_for_hrpsys(self)
def test_files_for_hrpsys_ros_bridge(self)
def check_if_file_exists_from_rospack(self, fname)
def pkg_config_variable(self, var)
def test_compile_iob(self)