aboutsummaryrefslogtreecommitdiff
path: root/test cases/common
diff options
context:
space:
mode:
authorMichael Hirsch <scivision@users.noreply.github.com>2020-07-12 22:40:26 -0400
committerJussi Pakkanen <jpakkane@gmail.com>2020-08-08 00:13:18 +0300
commitc5e3ce301235fadca77c8db05fc7b89bc04b57d3 (patch)
treedbc00c9b53906b81c31a82fa68c40a6e18c0a2d0 /test cases/common
parent02ea08ba66f5f9f076f205fca756fc8ebdd96f0f (diff)
downloadmeson-c5e3ce301235fadca77c8db05fc7b89bc04b57d3.zip
meson-c5e3ce301235fadca77c8db05fc7b89bc04b57d3.tar.gz
meson-c5e3ce301235fadca77c8db05fc7b89bc04b57d3.tar.bz2
common/234: avoid intermittent failure by dynamic path length generation
Diffstat (limited to 'test cases/common')
-rwxr-xr-xtest cases/common/234 very long commmand line/codegen.py5
-rw-r--r--test cases/common/234 very long commmand line/main.c6
-rw-r--r--test cases/common/234 very long commmand line/meson.build19
-rwxr-xr-xtest cases/common/234 very long commmand line/name_gen.py23
-rwxr-xr-xtest cases/common/234 very long commmand line/seq.py6
5 files changed, 39 insertions, 20 deletions
diff --git a/test cases/common/234 very long commmand line/codegen.py b/test cases/common/234 very long commmand line/codegen.py
index 4de78ce..b1de607 100755
--- a/test cases/common/234 very long commmand line/codegen.py
+++ b/test cases/common/234 very long commmand line/codegen.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
import sys
+from pathlib import Path
-with open(sys.argv[2], 'w') as f:
- print('int func{n}(void) {{ return {n}; }}'.format(n=sys.argv[1]), file=f)
+Path(sys.argv[2]).write_text(
+ 'int func{n}(void) {{ return {n}; }}'.format(n=sys.argv[1]))
diff --git a/test cases/common/234 very long commmand line/main.c b/test cases/common/234 very long commmand line/main.c
index dbb64a8..78f2de1 100644
--- a/test cases/common/234 very long commmand line/main.c
+++ b/test cases/common/234 very long commmand line/main.c
@@ -1,5 +1 @@
-int main(int argc, char **argv) {
- (void) argc;
- (void) argv;
- return 0;
-}
+int main(void) { return 0; }
diff --git a/test cases/common/234 very long commmand line/meson.build b/test cases/common/234 very long commmand line/meson.build
index fe47b5e..70058e6 100644
--- a/test cases/common/234 very long commmand line/meson.build
+++ b/test cases/common/234 very long commmand line/meson.build
@@ -6,6 +6,10 @@ if build_machine.system() == 'windows'
# cmd.exe: 8kb
# CreateProcess: 32kb
limit = 32767
+ # NOTE: filename limit is 260 characters unless
+ # 1. Python >= 3.6 is being used
+ # 2. Windows 10 registry has been edited to enable long pathnaems
+ # ninja backend uses absolute filenames, so we ensure they don't exceed 260.
elif build_machine.system() == 'cygwin'
# cygwin-to-win32: see above
# cygwin-to-cygwin: no limit?
@@ -18,20 +22,21 @@ else
limit = 131072
endif
# Now exceed that limit, but not so far that the test takes too long.
-name = 'ALongFilenameMuchLongerThanIsNormallySeenAndReallyHardToReadThroughToTheEndAMooseOnceBitMySisterSheNowWorksAtLLamaFreshFarmsThisHasToBeSoLongThatWeExceed128KBWithoutCompilingTooManyFiles'
-namelen = 187
+namelen = 260
nfiles = 50 + limit / namelen
message('Expected link commandline length is approximately ' + '@0@'.format((nfiles * (namelen+28))))
-seq = run_command('seq.py', '1', '@0@'.format(nfiles)).stdout().strip().split('\n')
+seq = run_command('name_gen.py', nfiles.to_string(), meson.build_root()).stdout().strip().split('\n')
sources = []
codegen = find_program('codegen.py')
-foreach i : seq
- sources += custom_target('codegen' + i,
- command: [codegen, i, '@OUTPUT@'],
- output: name + i + '.c')
+i=0
+foreach name : seq
+ sources += custom_target('codegen' + i.to_string(),
+ command: [codegen, i.to_string(), '@OUTPUT@'],
+ output: name + '.c')
+ i+=1
endforeach
shared_library('sharedlib', sources)
diff --git a/test cases/common/234 very long commmand line/name_gen.py b/test cases/common/234 very long commmand line/name_gen.py
new file mode 100755
index 0000000..8435298
--- /dev/null
+++ b/test cases/common/234 very long commmand line/name_gen.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python3
+"""
+generate sequence of filename that does not exceed MAX_LEN=260
+for Python < 3.6 and Windows without modified registry
+"""
+
+import sys
+import string
+
+name_len = 260 - len(sys.argv[2]) - 4 - 39 - 4 - 2
+if name_len < 1:
+ raise ValueError('The meson build directory pathname is so long '
+ 'that we cannot generate filenames within 260 characters.')
+# leave room for suffix and file separators, and meson generated text
+# e.g. ".c.obj.d" and other decorators added by Meson at configuration
+# for intermediate files
+
+base = string.ascii_letters * 5 # 260 characters
+max_num_len = len(str(sys.argv[1]))
+base = base[: name_len - max_num_len]
+
+for i in range(int(sys.argv[1])):
+ print("{base}{i:0{max_num_len}d}".format(base=base, max_num_len=max_num_len, i=i))
diff --git a/test cases/common/234 very long commmand line/seq.py b/test cases/common/234 very long commmand line/seq.py
deleted file mode 100755
index 637bf57..0000000
--- a/test cases/common/234 very long commmand line/seq.py
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/usr/bin/env python3
-
-import sys
-
-for i in range(int(sys.argv[1]), int(sys.argv[2])):
- print(i)