MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / checkEntryDatabase

Function checkEntryDatabase

test/sockets/test_getprotobyname.c:46–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46void checkEntryDatabase() {
47 struct protoent* entry;
48
49 // Don't call setprotoent() initially as getprotoent() should open the "database" if necessary.
50 entry = getprotoent();
51 assert(entry != NULL);
52 assert(strcmp("tcp", entry->p_name) == 0);
53
54 entry = getprotoent();
55 assert(entry != NULL);
56 assert(strcmp("udp", entry->p_name) == 0);
57
58 // Check that setprotoent() correctly sets the next entry to the first entry
59 setprotoent(1);
60
61 entry = getprotoent();
62 assert(entry != NULL);
63 assert(strcmp("tcp", entry->p_name) == 0);
64
65 entry = getprotoent();
66 assert(entry != NULL);
67 assert(strcmp("udp", entry->p_name) == 0);
68
69 // If we do a getprotoent() that goes past the end of the 'database' check that it returns NULL.
70 entry = getprotoent();
71 assert(entry == NULL);
72}
73
74int main() {
75 // First check getprotobyname() and getprotobynumber()

Callers 1

mainFunction · 0.85

Calls 4

getprotoentFunction · 0.85
strcmpFunction · 0.85
setprotoentFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected