Skip to content

Commit d36800b

Browse files
committed
test: add unit test for RTEMS/WINE compatibility handling
see #69 "If we're going to continue to support the old $RTEMS and $WINE, then they should be covered by the test"
1 parent b6723d0 commit d36800b

2 files changed

Lines changed: 81 additions & 5 deletions

File tree

cue-test.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import subprocess as sp
1414
import unittest
1515
import logging
16+
import fnmatch
1617
from argparse import Namespace
1718

1819
builddir = os.getcwd()
@@ -883,6 +884,77 @@ def test_archive7z(self):
883884
cue.extract_archive(hook, cwd=self.location)
884885
self.assertTrue(os.path.exists(self.new_file), "archive extract didn't add new file")
885886

887+
@unittest.skipIf(ci_os != 'linux', 'CrossCompatibilityHandling tests only apply to linux')
888+
class TestCrossCompatibilityHandling(unittest.TestCase):
889+
args = Namespace(paths=[])
890+
891+
def setUp(self):
892+
cue.clear_lists()
893+
os.environ.pop('CI_CROSS_TARGETS', None)
894+
os.environ.pop('RTEMS_TARGET', None)
895+
os.environ.pop('RTEMS', None)
896+
os.environ.pop('WINE', None)
897+
os.environ['MODULES'] = ''
898+
cue.detect_context()
899+
# Make cue.prepare() reconfigure base
900+
for root, dirs, files in os.walk(cue.ci['cachedir']):
901+
if 'checked_out' in files:
902+
if fnmatch.fnmatch(root, '*/base-*'):
903+
os.remove(os.path.join(root, 'checked_out'))
904+
905+
def runtest_rtems(self, arch, ver):
906+
cue.prepare(self.args)
907+
self.assertTrue('CI_CROSS_TARGETS' in os.environ, "CI_CROSS_TARGETS has not been set")
908+
self.assertTrue(os.environ['CI_CROSS_TARGETS'].startswith(':' + arch),
909+
"CI_CROSS_TARGETS is {0} (expected: :{1}...)"
910+
.format(os.environ['CI_CROSS_TARGETS'], arch))
911+
self.assertTrue(os.environ['CI_CROSS_TARGETS'].endswith('@' + ver),
912+
"CI_CROSS_TARGETS is {0} (expected: ...@{1})"
913+
.format(os.environ['CI_CROSS_TARGETS'], ver))
914+
915+
def test_RTEMS49_no_target(self):
916+
os.environ['RTEMS'] = '4.9'
917+
self.runtest_rtems('RTEMS-pc386', '4.9')
918+
919+
def test_RTEMS49_with_target(self):
920+
os.environ['RTEMS'] = '4.9'
921+
os.environ['RTEMS_TARGET'] = 'RTEMS-pc386'
922+
self.runtest_rtems('RTEMS-pc386', '4.9')
923+
924+
def test_RTEMS410_no_target(self):
925+
os.environ['RTEMS'] = '4.10'
926+
self.runtest_rtems('RTEMS-pc386', '4.10')
927+
928+
def test_RTEMS410_with_target(self):
929+
os.environ['RTEMS'] = '4.10'
930+
os.environ['RTEMS_TARGET'] = 'RTEMS-pc386'
931+
self.runtest_rtems('RTEMS-pc386', '4.10')
932+
933+
def test_RTEMS5_no_target(self):
934+
os.environ['RTEMS'] = '5'
935+
self.runtest_rtems('RTEMS-pc686', '5')
936+
937+
def test_RTEMS5_with_target(self):
938+
os.environ['RTEMS'] = '5'
939+
os.environ['RTEMS_TARGET'] = 'RTEMS-pc686'
940+
self.runtest_rtems('RTEMS-pc686', '5')
941+
942+
def test_WINE32(self):
943+
os.environ['WINE'] = '32'
944+
cue.prepare(self.args)
945+
self.assertTrue('CI_CROSS_TARGETS' in os.environ, "CI_CROSS_TARGETS has not been set")
946+
self.assertEqual(os.environ['CI_CROSS_TARGETS'], ':win32-x86-mingw',
947+
"CI_CROSS_TARGETS is {0} (expected: :win32-x86-mingw)"
948+
.format(os.environ['CI_CROSS_TARGETS']))
949+
950+
def test_WINE64(self):
951+
os.environ['WINE'] = '64'
952+
cue.prepare(self.args)
953+
self.assertTrue('CI_CROSS_TARGETS' in os.environ, "CI_CROSS_TARGETS has not been set")
954+
self.assertEqual(os.environ['CI_CROSS_TARGETS'], ':windows-x64-mingw',
955+
"CI_CROSS_TARGETS is {0} (expected: :windows-x64-mingw)"
956+
.format(os.environ['CI_CROSS_TARGETS']))
957+
886958

887959
if __name__ == "__main__":
888960
if 'VV' in os.environ and os.environ['VV'] == '1':

cue.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ def detect_context():
174174

175175
def clear_lists():
176176
global is_base314, has_test_results, silent_dep_builds, is_make3
177+
global _modified_files, do_recompile, building_base
177178
del seen_setups[:]
178179
del modules_to_compile[:]
179180
del extra_makeargs[:]
@@ -821,12 +822,15 @@ def handle_old_cross_variables():
821822
if "RTEMS" in os.environ:
822823
if 'RTEMS_TARGET' in os.environ:
823824
rtems_target = os.environ['RTEMS_TARGET']
824-
elif os.path.exists(os.path.join(places['EPICS_BASE'], 'configure', 'os',
825-
'CONFIG.Common.RTEMS-pc386-qemu')):
826-
# Base 3.15 doesn't have -qemu target architecture
827-
rtems_target = 'RTEMS-pc386-qemu'
828825
else:
829-
rtems_target = 'RTEMS-pc386'
826+
if os.environ['RTEMS'] == '5':
827+
rtems_target = 'RTEMS-pc686-qemu'
828+
else:
829+
rtems_target = 'RTEMS-pc386'
830+
if os.path.exists(os.path.join(places['EPICS_BASE'], 'configure', 'os',
831+
'CONFIG.Common.RTEMS-pc386-qemu')):
832+
# Base 3.15 doesn't have -qemu target architecture
833+
rtems_target = 'RTEMS-pc386-qemu'
830834

831835
new_cross_target = ":" + rtems_target + "@" + os.environ["RTEMS"]
832836
os.environ["CI_CROSS_TARGETS"] += new_cross_target

0 commit comments

Comments
 (0)