github.phpd.cn/thought-machine/please@v12.2.0+incompatible/test/cc_rules/gcc/test.c (about)

     1  // Manual test to prove the C rules work.
     2  
     3  #include <stdio.h>
     4  #include <stdlib.h>
     5  #include <string.h>
     6  
     7  char kTemplate[] = "<testsuite errors=\"0\" failures=\"0\"></testsuite>";
     8  
     9  int main(int argc, char** argv) {
    10    // The following line is legal C but not legal C++.
    11    char* buf = malloc(strlen(kTemplate) * sizeof(char) + 1);
    12    strcpy(buf, kTemplate);
    13    FILE* f = fopen("test.results", "w");
    14    fprintf(f, "%s\n", buf);
    15    fclose(f);
    16    printf("%d %s\n", argc, argv[0]);
    17    return 0;
    18  }