1// RUN: %clangxx_msan -O0 -g %s -lutil -o %t && %run %t
2
3#include <assert.h>
4#include <pty.h>
5#include <unistd.h>
6#include <cstring>
7
8#include <sanitizer/msan_interface.h>
9
10int
11main (int argc, char** argv)
12{
13 int parent, worker;
14 openpty(amaster: &parent, aslave: &worker, NULL, NULL, NULL);
15 assert(__msan_test_shadow(&parent, sizeof(parent)) == -1);
16 assert(__msan_test_shadow(&worker, sizeof(worker)) == -1);
17
18 char name[255];
19 ttyname_r(fd: parent, buf: name, buflen: sizeof(name));
20 assert(__msan_test_shadow(name, strlen(name) + 1) == -1);
21
22 char *name_p = ttyname(fd: parent);
23 assert(__msan_test_shadow(name_p, strlen(name_p) + 1) == -1);
24
25 int parent2;
26 forkpty(amaster: &parent2, NULL, NULL, NULL);
27 assert(__msan_test_shadow(&parent2, sizeof(parent2)) == -1);
28}
29

source code of compiler-rt/test/msan/Linux/forkpty.cpp