summaryrefslogtreecommitdiffstats
path: root/test cases/common/227 very long commmand line
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:41:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:41:38 +0000
commit7b6e527f440cd7e6f8be2b07cee320ee6ca18786 (patch)
tree4a2738d69fa2814659fdadddf5826282e73d81f4 /test cases/common/227 very long commmand line
parentInitial commit. (diff)
downloadmeson-7b6e527f440cd7e6f8be2b07cee320ee6ca18786.tar.xz
meson-7b6e527f440cd7e6f8be2b07cee320ee6ca18786.zip
Adding upstream version 1.0.1.upstream/1.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test cases/common/227 very long commmand line')
-rwxr-xr-xtest cases/common/227 very long commmand line/codegen.py7
-rw-r--r--test cases/common/227 very long commmand line/main.c1
-rw-r--r--test cases/common/227 very long commmand line/meson.build49
-rwxr-xr-xtest cases/common/227 very long commmand line/name_gen.py23
4 files changed, 80 insertions, 0 deletions
diff --git a/test cases/common/227 very long commmand line/codegen.py b/test cases/common/227 very long commmand line/codegen.py
new file mode 100755
index 0000000..b1de607
--- /dev/null
+++ b/test cases/common/227 very long commmand line/codegen.py
@@ -0,0 +1,7 @@
+#!/usr/bin/env python3
+
+import sys
+from pathlib import Path
+
+Path(sys.argv[2]).write_text(
+ 'int func{n}(void) {{ return {n}; }}'.format(n=sys.argv[1]))
diff --git a/test cases/common/227 very long commmand line/main.c b/test cases/common/227 very long commmand line/main.c
new file mode 100644
index 0000000..78f2de1
--- /dev/null
+++ b/test cases/common/227 very long commmand line/main.c
@@ -0,0 +1 @@
+int main(void) { return 0; }
diff --git a/test cases/common/227 very long commmand line/meson.build b/test cases/common/227 very long commmand line/meson.build
new file mode 100644
index 0000000..f8df311
--- /dev/null
+++ b/test cases/common/227 very long commmand line/meson.build
@@ -0,0 +1,49 @@
+project('very long command lines', 'c')
+
+# Get the current system's commandline length limit.
+if build_machine.system() == 'windows'
+ # Various limits on 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?
+ # Cygwin is slow, so only test it lightly here.
+ limit = 8192
+else
+ # ninja passes whole line as a single argument, for which
+ # the limit is 128k as of Linux 2.6.23. See MAX_ARG_STRLEN.
+ # BSD seems similar, see https://www.in-ulm.de/~mascheck/various/argmax
+ limit = 131072
+endif
+# Now exceed that limit, but not so far that the test takes too long.
+namelen = 260
+nfiles = 50 + limit / namelen
+message('Expected link commandline length is approximately ' + '@0@'.format((nfiles * (namelen+28))))
+
+seq = run_command('name_gen.py', nfiles.to_string(), meson.build_root(), check: true).stdout().strip().split('\n')
+
+sources = []
+codegen = find_program('codegen.py')
+
+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)
+static_library('staticlib', sources)
+executable('app', 'main.c', sources)
+
+# Also test short commandlines to make sure that doesn't regress
+shared_library('sharedlib0', sources[0])
+static_library('staticlib0', sources[0])
+executable('app0', 'main.c', sources[0])
diff --git a/test cases/common/227 very long commmand line/name_gen.py b/test cases/common/227 very long commmand line/name_gen.py
new file mode 100755
index 0000000..8435298
--- /dev/null
+++ b/test cases/common/227 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))