diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:41:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:41:38 +0000 |
commit | 7b6e527f440cd7e6f8be2b07cee320ee6ca18786 (patch) | |
tree | 4a2738d69fa2814659fdadddf5826282e73d81f4 /test cases/native/3 pipeline | |
parent | Initial commit. (diff) | |
download | meson-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/native/3 pipeline')
-rwxr-xr-x | test cases/native/3 pipeline/depends/copyrunner.py | 7 | ||||
-rw-r--r-- | test cases/native/3 pipeline/depends/filecopier.c | 23 | ||||
-rw-r--r-- | test cases/native/3 pipeline/depends/libsrc.c.in | 3 | ||||
-rw-r--r-- | test cases/native/3 pipeline/depends/meson.build | 11 | ||||
-rw-r--r-- | test cases/native/3 pipeline/depends/prog.c | 5 | ||||
-rw-r--r-- | test cases/native/3 pipeline/input_src.dat | 1 | ||||
-rw-r--r-- | test cases/native/3 pipeline/meson.build | 23 | ||||
-rw-r--r-- | test cases/native/3 pipeline/prog.c | 5 | ||||
-rw-r--r-- | test cases/native/3 pipeline/src/input_src.dat | 1 | ||||
-rw-r--r-- | test cases/native/3 pipeline/src/meson.build | 12 | ||||
-rw-r--r-- | test cases/native/3 pipeline/src/prog.c | 9 | ||||
-rw-r--r-- | test cases/native/3 pipeline/src/srcgen.c | 40 | ||||
-rw-r--r-- | test cases/native/3 pipeline/srcgen.c | 69 |
13 files changed, 209 insertions, 0 deletions
diff --git a/test cases/native/3 pipeline/depends/copyrunner.py b/test cases/native/3 pipeline/depends/copyrunner.py new file mode 100755 index 0000000..0ef6a6d --- /dev/null +++ b/test cases/native/3 pipeline/depends/copyrunner.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 + +import sys, subprocess + +prog, infile, outfile = sys.argv[1:] + +subprocess.check_call([prog, infile, outfile]) diff --git a/test cases/native/3 pipeline/depends/filecopier.c b/test cases/native/3 pipeline/depends/filecopier.c new file mode 100644 index 0000000..e10e4e7 --- /dev/null +++ b/test cases/native/3 pipeline/depends/filecopier.c @@ -0,0 +1,23 @@ +#include<stdio.h> +#include<assert.h> + +#define BUFSIZE 1024 + +int main(int argc, char **argv) { + char buffer[BUFSIZE]; + size_t num_read; + size_t num_written; + FILE *fin = fopen(argv[1], "rb"); + FILE *fout; + assert(argc>0); + assert(fin); + num_read = fread(buffer, 1, BUFSIZE, fin); + assert(num_read > 0); + fclose(fin); + fout = fopen(argv[2], "wb"); + assert(fout); + num_written = fwrite(buffer, 1, num_read, fout); + assert(num_written == num_read); + fclose(fout); + return 0; +} diff --git a/test cases/native/3 pipeline/depends/libsrc.c.in b/test cases/native/3 pipeline/depends/libsrc.c.in new file mode 100644 index 0000000..8180551 --- /dev/null +++ b/test cases/native/3 pipeline/depends/libsrc.c.in @@ -0,0 +1,3 @@ +int func(void) { + return 42; +} diff --git a/test cases/native/3 pipeline/depends/meson.build b/test cases/native/3 pipeline/depends/meson.build new file mode 100644 index 0000000..5111fee --- /dev/null +++ b/test cases/native/3 pipeline/depends/meson.build @@ -0,0 +1,11 @@ +runner = find_program('copyrunner.py') + +copier = executable('copier', 'filecopier.c', native: true) + +cg = generator(runner, + output: ['@BASENAME@.c'], + arguments: [copier.full_path(), '@INPUT@', '@OUTPUT@'], + depends: copier) + +test('generatordep', + executable('gd', 'prog.c', cg.process('libsrc.c.in'))) diff --git a/test cases/native/3 pipeline/depends/prog.c b/test cases/native/3 pipeline/depends/prog.c new file mode 100644 index 0000000..54c40e1 --- /dev/null +++ b/test cases/native/3 pipeline/depends/prog.c @@ -0,0 +1,5 @@ +int func(void); + +int main(void) { + return func() != 42; +} diff --git a/test cases/native/3 pipeline/input_src.dat b/test cases/native/3 pipeline/input_src.dat new file mode 100644 index 0000000..a324dca --- /dev/null +++ b/test cases/native/3 pipeline/input_src.dat @@ -0,0 +1 @@ +int func(void) { return 0; } diff --git a/test cases/native/3 pipeline/meson.build b/test cases/native/3 pipeline/meson.build new file mode 100644 index 0000000..e12cb7b --- /dev/null +++ b/test cases/native/3 pipeline/meson.build @@ -0,0 +1,23 @@ +project('pipeline test', 'c') + +# We need to run this executable locally so build it with +# the host compiler. +e1 = executable('srcgen', 'srcgen.c', native : true) + +# Generate a source file that needs to be included in the build. +gen = generator(e1, \ + depfile : '@BASENAME@.d', + output : '@BASENAME@.c', # Line continuation inside arguments should work without needing a "\". + arguments : ['@INPUT@', '@OUTPUT@', '@DEPFILE@']) + +generated = gen.process(['input_src.dat']) + +e2 = executable('prog', 'prog.c', generated) + +test('pipelined', e2) + +# This is in a subdirectory to make sure +# we write proper subdir paths to output. +subdir('src') + +subdir('depends') diff --git a/test cases/native/3 pipeline/prog.c b/test cases/native/3 pipeline/prog.c new file mode 100644 index 0000000..128f2bb --- /dev/null +++ b/test cases/native/3 pipeline/prog.c @@ -0,0 +1,5 @@ +int func(void); + +int main(void) { + return func(); +} diff --git a/test cases/native/3 pipeline/src/input_src.dat b/test cases/native/3 pipeline/src/input_src.dat new file mode 100644 index 0000000..354499a --- /dev/null +++ b/test cases/native/3 pipeline/src/input_src.dat @@ -0,0 +1 @@ +#include<stdio.h> diff --git a/test cases/native/3 pipeline/src/meson.build b/test cases/native/3 pipeline/src/meson.build new file mode 100644 index 0000000..4e9ac11 --- /dev/null +++ b/test cases/native/3 pipeline/src/meson.build @@ -0,0 +1,12 @@ +e1 = executable('srcgen', 'srcgen.c', native : true) + +# Generate a header file that needs to be included. +gen = generator(e1, + output : '@BASENAME@.h', + arguments : ['@INPUT@', '@OUTPUT@']) + +generated = gen.process('input_src.dat') + +e2 = executable('prog', 'prog.c', generated) + +test('pipelined', e2) diff --git a/test cases/native/3 pipeline/src/prog.c b/test cases/native/3 pipeline/src/prog.c new file mode 100644 index 0000000..83121b5 --- /dev/null +++ b/test cases/native/3 pipeline/src/prog.c @@ -0,0 +1,9 @@ +#include"input_src.h" + +int main(void) { + void *foo = printf; + if(foo) { + return 0; + } + return 1; +} diff --git a/test cases/native/3 pipeline/src/srcgen.c b/test cases/native/3 pipeline/src/srcgen.c new file mode 100644 index 0000000..26761d2 --- /dev/null +++ b/test cases/native/3 pipeline/src/srcgen.c @@ -0,0 +1,40 @@ +#include<stdio.h> +#include<assert.h> + +#define ARRSIZE 80 + +int main(int argc, char **argv) { + char arr[ARRSIZE]; + char *ifilename; + char *ofilename; + FILE *ifile; + FILE *ofile; + size_t bytes; + + if(argc != 3) { + fprintf(stderr, "%s <input file> <output file>\n", argv[0]); + return 1; + } + ifilename = argv[1]; + ofilename = argv[2]; + printf("%s\n", ifilename); + ifile = fopen(ifilename, "r"); + if(!ifile) { + fprintf(stderr, "Could not open source file %s.\n", ifilename); + return 1; + } + ofile = fopen(ofilename, "w"); + if(!ofile) { + fprintf(stderr, "Could not open target file %s\n", ofilename); + fclose(ifile); + return 1; + } + bytes = fread(arr, 1, ARRSIZE, ifile); + assert(bytes < 80); + assert(bytes > 0); + fwrite(arr, 1, bytes, ofile); + + fclose(ifile); + fclose(ofile); + return 0; +} diff --git a/test cases/native/3 pipeline/srcgen.c b/test cases/native/3 pipeline/srcgen.c new file mode 100644 index 0000000..ceb9ecc --- /dev/null +++ b/test cases/native/3 pipeline/srcgen.c @@ -0,0 +1,69 @@ +#include<stdio.h> +#include<assert.h> +#include<string.h> + +#define ARRSIZE 80 + +int main(int argc, char **argv) { + char arr[ARRSIZE]; + char *ofilename; + char *ifilename; + char *dfilename; + FILE *ifile; + FILE *ofile; + FILE *depfile; + size_t bytes; + int i; + + if(argc != 4) { + fprintf(stderr, "%s <input file> <output file> <dependency file>\n", argv[0]); + return 1; + } + ifilename = argv[1]; + ofilename = argv[2]; + dfilename = argv[3]; + ifile = fopen(argv[1], "r"); + if(!ifile) { + fprintf(stderr, "Could not open source file %s.\n", argv[1]); + return 1; + } + ofile = fopen(ofilename, "w"); + if(!ofile) { + fprintf(stderr, "Could not open target file %s\n", ofilename); + fclose(ifile); + return 1; + } + bytes = fread(arr, 1, ARRSIZE, ifile); + assert(bytes < 80); + assert(bytes > 0); + fwrite(arr, 1, bytes, ofile); + + depfile = fopen(dfilename, "w"); + if(!depfile) { + fprintf(stderr, "Could not open depfile %s\n", ofilename); + fclose(ifile); + fclose(ofile); + return 1; + } + for(i=0; i<strlen(ofilename); i++) { + if(ofilename[i] == ' ') { + fwrite("\\ ", 1, 2, depfile); + } else { + fwrite(&ofilename[i], 1, 1, depfile); + } + } + fwrite(": ", 1, 2, depfile); + for(i=0; i<strlen(ifilename); i++) { + if(ifilename[i] == ' ') { + fwrite("\\ ", 1, 2, depfile); + } else { + fwrite(&ifilename[i], 1, 1, depfile); + } + } + fwrite("\n", 1, 1, depfile); + + fclose(ifile); + fclose(ofile); + fclose(depfile); + return 0; +} |