• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 The Bazel Authors. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include <stdio.h>
16 #include <string.h>
17 
main(int argc,char ** argv)18 int main(int argc, char** argv) {
19   static const char* kExpected[] = {
20     "a b",
21     "c d",
22     "tests/native_binary/testdata.txt",
23     "$(location",
24     "testdata.txt)",
25     "tests/native_binary/testdata.txt",
26     "tests/native_binary/testdata.txt $(location testdata.txt) tests/native_binary/testdata.txt",
27     "$TEST_SRCDIR",
28 
29     // TODO(laszlocsomor): uncomment this (and its counterpart in the BUILD
30     // file) after https://github.com/bazelbuild/bazel/issues/6622 is resolved
31     // and the Bash-less test wrapper is the default on Windows.
32     // "${TEST_SRCDIR}",
33 
34     "",
35   };
36 
37   for (int i = 1; i < argc; ++i) {
38     if (!kExpected[i - 1][0]) {
39       fprintf(stderr, "too many arguments, expected only %d\n", i);
40       return 1;
41     }
42     if (argc < i) {
43       fprintf(stderr, "expected more than %d arguments\n", i);
44       return 1;
45     }
46     if (strcmp(argv[i], kExpected[i - 1]) != 0) {
47       fprintf(stderr, "argv[%d]=(%s), expected (%s)\n", i, argv[i],
48               kExpected[i - 1]);
49       return 1;
50     }
51   }
52   return 0;
53 }
54