sbsv2/raptor/test/smoke_suite/longfilenames.py
author Zheng Shen <zheng.shen@nokia.com>
Tue, 26 Oct 2010 11:12:31 +0800
changeset 654 7c11c3d8d025
parent 591 22486c9c7b15
permissions -rw-r--r--
romtools 13.2.0.1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
591
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
     1
#
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
     2
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
     3
# All rights reserved.
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
     4
# This component and the accompanying materials are made available
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
     6
# which accompanies this distribution, and is available
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
     8
#
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
     9
# Initial Contributors:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    10
# Nokia Corporation - initial contribution.
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    11
#
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    12
# Contributors:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    13
#
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    14
# Description: 
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    15
#
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    16
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    17
from raptor_tests import SmokeTest
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    18
import os
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    19
import re
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    20
import sys
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    21
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    22
def run():
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    23
	# Content for files to be generated.
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    24
	cpp = "longerfilenamethanyoumightnormallyexpecttobepresent"
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    25
	path = "/test/smoke_suite/test_resources/longfilenames/"
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    26
	targetinfo = """TARGET			longfilenames.exe
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    27
TARGETTYPE		exe
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    28
UID				0xE8000047
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    29
LIBRARY			euser.lib
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    30
SYSTEMINCLUDE	/epoc32/include
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    31
"""
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    32
	
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    33
	# Some numbers for path and file operations
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    34
	length_limit = 245 # Safety-margin of 10 chars for changing dir structures in Raptor
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    35
	extLen = 8 # eg. _001.o.d
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    36
	numLen = 43 # release directory length (c_0000000000000000/longfilenames_exe/winscw/urel/) (minus a few as a safety-margin)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    37
	pathmultiplier = 5	# expand cpp to the maximum length
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    38
	mmpStart = 1
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    39
	mmpStop = 270
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    40
	cppStart = 1
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    41
	cppStop = 270
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    42
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    43
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    44
	# Find SBS_Home and its length as a string
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    45
	sbsHome = os.environ["SBS_HOME"]
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    46
	sbsLen = len(sbsHome)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    47
	
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    48
	# Work out path lengths required
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    49
	dirname = sbsHome + path
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    50
	string = cpp * pathmultiplier
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    51
	dirlen = len(dirname)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    52
	fileLen = length_limit - dirlen - numLen - extLen
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    53
	if fileLen < 0:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    54
		print "Error: Your test path is too long for the longfilenames test to work"
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    55
		sys.exit()
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    56
	fileName = string[0:fileLen]
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    57
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    58
	# Generate the mmp file using the mmp string
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    59
	f = open(dirname + 'longfilenames.mmp', 'w')
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    60
	f.writelines(targetinfo)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    61
	f.writelines("\nSOURCE		" + cpp + ".cpp\n")
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    62
	while mmpStart <= mmpStop:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    63
		sourceinfo = "SOURCE		" + fileName + '_%03d' %mmpStart + ".cpp " + '\n'
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    64
		f.writelines(sourceinfo)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    65
		mmpStart += 1
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    66
	f.close()
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    67
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    68
	# File generating utility
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    69
	while cppStart <= cppStop:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    70
		t = str(cppStart)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    71
		filename = dirname + fileName + '_%03d' %cppStart + '.cpp'
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    72
		content = 'int x' + t + ' = 1;'
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    73
		f = open (filename, 'w')
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    74
		f.write (content)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    75
		f.close()
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    76
		cppStart += 1
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    77
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    78
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    79
	t = SmokeTest()
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    80
	t.id = "79"
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    81
	t.name = "longfilenames"
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    82
	t.command = "sbs -b smoke_suite/test_resources/longfilenames/bld.inf -c winscw"
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    83
	t.description = """Ensure that winscw links with large amounts of object files with long names are buildable.
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    84
		Note that the link in the build of this component should always be greater than 16500 chars, regardless
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    85
		of environment - we know such calls are currently problematic on Windows with GNU Make and Cygwin's
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    86
		Bash unless a linker response file is not used to hold the object files."""
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    87
	t.targets = [
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    88
		"$(EPOCROOT)/epoc32/release/winscw/urel/longfilenames.exe",
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    89
		"$(EPOCROOT)/epoc32/release/winscw/urel/longfilenames.exe.map"
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    90
		]
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    91
	t.addbuildtargets('smoke_suite/test_resources/longfilenames/bld.inf', [
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    92
		"longfilenames_exe/winscw/urel/longerfilenamethanyoumightnormallyexpecttobepresent.dep",
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    93
		"longfilenames_exe/winscw/urel/longerfilenamethanyoumightnormallyexpecttobepresent.o",
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    94
		"longfilenames_exe/winscw/urel/longerfilenamethanyoumightnormallyexpecttobepresent.o.d",
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    95
		"longfilenames_exe/winscw/urel/longfilenames.UID.CPP",
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    96
		"longfilenames_exe/winscw/urel/longfilenames_UID_.dep",
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    97
		"longfilenames_exe/winscw/urel/longfilenames_UID_.o",
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    98
		"longfilenames_exe/winscw/urel/longfilenames_UID_.o.d",
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    99
		"longfilenames_exe/winscw/urel/longfilenames_urel_objects.lrf"]
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   100
		)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   101
	
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   102
	basefilename = "longfilenames_exe/winscw/urel/" + fileName + "_%03d.%s"
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   103
	for i in range(1, 271):		
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   104
		t.addbuildtargets('smoke_suite/test_resources/longfilenames/bld.inf', [
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   105
			basefilename % (i, "dep"),
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   106
			basefilename % (i, "o"),
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   107
			basefilename % (i, "o.d")
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   108
			]
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   109
		)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   110
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   111
	t.run()
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   112
		
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   113
	# Remove all created files
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   114
	
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   115
	# Matches longerfilena......_nnn.cpp
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   116
	cpp_regex = re.compile("^.+_\d{3}.cpp$", re.I)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   117
	for file in os.listdir(dirname):
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   118
		if cpp_regex.match(file) is not None:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   119
			try:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   120
				os.remove(dirname + file)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   121
			except:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   122
				pass
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   123
	
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   124
	try:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   125
		os.remove(dirname + 'longfilenames.mmp')
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   126
	except:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   127
		pass
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   128
	
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   129
	return t