Files
clang-p2996/compiler-rt/test/sanitizer_common/TestCases/Linux/ptsname.c
Vitaly Buka 7475bd5411 [Msan] Add ptsname, ptsname_r interceptors
Reviewed By: eugenis, MaskRay

Differential Revision: https://reviews.llvm.org/D88547
2020-09-30 15:00:52 -07:00

28 lines
472 B
C

// RUN: %clang %s -o %t && %run %t
#define _GNU_SOURCE
#define _XOPEN_SOURCE 600
#include <assert.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main() {
int pt = posix_openpt(O_NOCTTY);
if (pt == -1)
return 0;
char *s = ptsname(pt);
assert(s);
assert(strstr(s, "/dev"));
char buff[1000] = {};
int r = ptsname_r(pt, buff, sizeof(buff));
assert(!r);
assert(strstr(buff, "/dev"));
close(pt);
return 0;
}