私は、bitten によって呼び出される継続的な統合とテストに使用される python スクリプトを作成しています。単体テストでは、Google テスト フレームワークを使用します。各ソフトウェア コンポーネントには、構成およびその他の必要なサービスを実行し、gtest 実行可能ファイルを実行する bash スクリプトがあります。Python スクリプトは、bash スクリプトを探してリポジトリを調べ、os.popen() コマンドを使用して各スクリプトを呼び出します。
Python スクリプト (UnitTest.py)
#!/usr/bin/python
import os
import fnmatch
import sys
import subprocess
repository_location = '/home/actuv/workspace/eclipse/iccs/'
unit_test_script_name = 'RunUnitTests.sh'
def file_locator(repo, script_name):
# Function for determining all unit test scripts
test_location = []
for root, dirnames, filenames in os.walk(repo):
for filename in fnmatch.filter(filenames, script_name):
test_location.append(os.path.join(root))
return test_location
def run_tests(test_locations, script_name):
# Runs test scripts located at each test location
for tests in test_locations:
cmd = 'cd ' + tests + ';./' + script_name
print 'Running Unit Test at: ' + tests
os.popen(cmd)
################ MAIN ################
# Find Test Locations
script_locations = file_locator(repository_location, unit_test_script_name)
# Run tests located at each location
run_tests(script_locations)
# End of tests
sys.exit(0)
バッシュスクリプト
#!/bin/sh
echo "Running unit tests..."
# update the LD_LIBRARY_PATH to include paths to our shared libraries
# start the test server
# Run the tests
# wait to allow all processes to end before terminating the server
sleep 10s
ターミナル ウィンドウから bash スクリプトを手動で実行すると、問題なく実行されます。Python スクリプトで bash スクリプトを呼び出すと、bash スクリプトの TestSingleClient および TestMultiClientLA 行でセグメンテーション エラーが発生します。