This revision was automatically updated to reflect the committed changes. Closed by commit rL350229: [sanitizer_common] Add tests for more *putc and *getc variants (authored by mgorny, committed by ). Herald added a subscriber: delcypher.
Changed prior to commit: https://reviews.llvm.org/D56152?vs=179711&id=179868#toc Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D56152/new/ https://reviews.llvm.org/D56152 Files: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/fputc_putc_putchar.cc compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/getc_unlocked.cc compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/putc_putchar_unlocked.cc Index: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/fputc_putc_putchar.cc =================================================================== --- compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/fputc_putc_putchar.cc +++ compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/fputc_putc_putchar.cc @@ -0,0 +1,13 @@ +// RUN: %clangxx -g %s -o %t && %run %t | FileCheck %s +// CHECK: abc + +#include <assert.h> +#include <stdio.h> + +int main(void) { + assert(fputc('a', stdout) != EOF); + assert(putc('b', stdout) != EOF); + assert(putchar('c') != EOF); + + return 0; +} Index: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/putc_putchar_unlocked.cc =================================================================== --- compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/putc_putchar_unlocked.cc +++ compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/putc_putchar_unlocked.cc @@ -0,0 +1,12 @@ +// RUN: %clangxx -g %s -o %t && %run %t | FileCheck %s +// CHECK: bc + +#include <assert.h> +#include <stdio.h> + +int main(void) { + assert(putc_unlocked('b', stdout) != EOF); + assert(putchar_unlocked('c') != EOF); + + return 0; +} Index: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/getc_unlocked.cc =================================================================== --- compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/getc_unlocked.cc +++ compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/getc_unlocked.cc @@ -0,0 +1,20 @@ +// RUN: %clangxx -g %s -o %t && %run %t + +#include <assert.h> +#include <stdio.h> + +int main(int argc, char **argv) { + FILE *fp = fopen(argv[0], "r"); + assert(fp); + + // the file should be at least one character long, always + assert(getc_unlocked(fp) != EOF); + // POSIX guarantees being able to ungetc() at least one character + // NB: ungetc_unlocked is apparently not present + assert(ungetc('X', fp) != EOF); + // check whether ungetc() works with getc_unlocked() + assert(getc_unlocked(fp) == 'X'); + + assert(!fclose(fp)); + return 0; +}
Index: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/fputc_putc_putchar.cc =================================================================== --- compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/fputc_putc_putchar.cc +++ compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/fputc_putc_putchar.cc @@ -0,0 +1,13 @@ +// RUN: %clangxx -g %s -o %t && %run %t | FileCheck %s +// CHECK: abc + +#include <assert.h> +#include <stdio.h> + +int main(void) { + assert(fputc('a', stdout) != EOF); + assert(putc('b', stdout) != EOF); + assert(putchar('c') != EOF); + + return 0; +} Index: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/putc_putchar_unlocked.cc =================================================================== --- compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/putc_putchar_unlocked.cc +++ compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/putc_putchar_unlocked.cc @@ -0,0 +1,12 @@ +// RUN: %clangxx -g %s -o %t && %run %t | FileCheck %s +// CHECK: bc + +#include <assert.h> +#include <stdio.h> + +int main(void) { + assert(putc_unlocked('b', stdout) != EOF); + assert(putchar_unlocked('c') != EOF); + + return 0; +} Index: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/getc_unlocked.cc =================================================================== --- compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/getc_unlocked.cc +++ compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/getc_unlocked.cc @@ -0,0 +1,20 @@ +// RUN: %clangxx -g %s -o %t && %run %t + +#include <assert.h> +#include <stdio.h> + +int main(int argc, char **argv) { + FILE *fp = fopen(argv[0], "r"); + assert(fp); + + // the file should be at least one character long, always + assert(getc_unlocked(fp) != EOF); + // POSIX guarantees being able to ungetc() at least one character + // NB: ungetc_unlocked is apparently not present + assert(ungetc('X', fp) != EOF); + // check whether ungetc() works with getc_unlocked() + assert(getc_unlocked(fp) == 'X'); + + assert(!fclose(fp)); + return 0; +}
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits