1 // RUN: %clangxx -O0 -g %s -o %t 2 // 3 // REQUIRES: freebsd, netbsd 4 5 #include <assert.h> 6 #include <stdlib.h> 7 #include <ttyent.h> 8 9 #include <assert.h> 10 #include <stdlib.h> 11 #include <ttyent.h> 12 test1()13void test1() { 14 struct ttyent *typ = getttyent(); 15 assert(typ && typ->ty_name != nullptr); 16 assert(typ->ty_type != nullptr); 17 endttyent(); 18 } 19 test2()20void test2() { 21 struct ttyent *typ = getttynam("console"); 22 assert(typ && typ->ty_name != nullptr); 23 assert(typ->ty_type != nullptr); 24 endttyent(); 25 } 26 test3()27void test3() { 28 if (!setttyent()) 29 exit(1); 30 31 struct ttyent *typ = getttyent(); 32 assert(typ && typ->ty_name != nullptr); 33 assert(typ->ty_type != nullptr); 34 endttyent(); 35 } 36 37 #if defined(__NetBSD__) test4()38void test4() { 39 if (!setttyentpath(_PATH_TTYS)) 40 exit(1); 41 42 struct ttyent *typ = getttyent(); 43 assert(typ && typ->ty_name != nullptr); 44 assert(typ->ty_type != nullptr); 45 assert(typ->ty_class != nullptr); 46 47 endttyent(); 48 } 49 #endif 50 main(void)51int main(void) { 52 test1(); 53 test2(); 54 test3(); 55 #if defined(__NetBSD__) 56 test4(); 57 #endif 58 59 return 0; 60 } 61