/*------------------------------------------------------------------------- * Function: main * * Purpose: Test links * * Return: Success: exit(0) * * Failure: exit(non-zero) * * Programmer: Robb Matzke * Friday, August 14, 1998 * * Modifications: * *------------------------------------------------------------------------- */ int main(void) { int nerrors = 0; hid_t fapl; h5_reset(); fapl = h5_fileaccess(); /* The tests... */ nerrors += mklinks(fapl) < 0 ? 1 : 0; nerrors += cklinks(fapl) < 0 ? 1 : 0; nerrors += new_links(fapl) < 0 ? 1 : 0; nerrors += ck_new_links(fapl) < 0 ? 1 : 0; nerrors += long_links(fapl) < 0 ? 1 : 0; nerrors += toomany(fapl) < 0 ? 1 : 0; nerrors += ud_link_compat(fapl) < 0 ? 1 : 0; nerrors += group_version_macros(fapl) < 0 ? 1 : 0; /* Results */ if (nerrors) { printf("***** %d LINK TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); exit(1); } printf("All link tests passed.\n"); h5_cleanup(FILENAME, fapl); return 0; }
core * new_state (int symbol) { int n; core *p; short *isp1; short *isp2; short *iend; #ifdef TRACE fprintf(stderr, "Entering new_state, symbol = %d\n", symbol); #endif if (nstates >= MAXSHORT) toomany("states"); isp1 = kernel_base[symbol]; iend = kernel_end[symbol]; n = iend - isp1; p = (core *) mallocate((unsigned) (sizeof(core) + (n - 1) * sizeof(short))); p->accessing_symbol = symbol; p->number = nstates; p->nitems = n; isp2 = p->items; while (isp1 < iend) *isp2++ = *isp1++; last_state->next = p; last_state = p; nstates++; return (p); }
set_goto_map() { register shifts *sp; register int i; register int symbol; register int k; register short *temp_map; register int state2; register int state1; goto_map = NEW2(nvars + 1, short) - ntokens; temp_map = NEW2(nvars + 1, short) - ntokens; ngotos = 0; for (sp = first_shift; sp; sp = sp->next) { for (i = sp->nshifts - 1; i >= 0; i--) { symbol = accessing_symbol[sp->shifts[i]]; if (ISTOKEN(symbol)) break; if (ngotos == MAXSHORT) toomany("gotos"); ngotos++; goto_map[symbol]++; } } k = 0; for (i = ntokens; i < nsyms; i++) { temp_map[i] = k; k += goto_map[i]; } for (i = ntokens; i < nsyms; i++) goto_map[i] = temp_map[i]; goto_map[nsyms] = ngotos; temp_map[nsyms] = ngotos; from_state = NEW2(ngotos, short); to_state = NEW2(ngotos, short); for (sp = first_shift; sp; sp = sp->next) { state1 = sp->number; for (i = sp->nshifts - 1; i >= 0; i--) { state2 = sp->shifts[i]; symbol = accessing_symbol[state2]; if (ISTOKEN(symbol)) break; k = temp_map[symbol]++; from_state[k] = state1; to_state[k] = state2; } } FREE(temp_map + ntokens); }
int main() { if (Cookies_rc_check()) { MSG("If you change cookiesrc, remember to stop the DPIs via dpidc.\n"); return 1; } a_Cookies_set("name=val", "ordinary.com", "/", NULL); expect(__LINE__, "Cookie: name=val\r\n", "http", "ordinary.com", "/"); toomany(); maxage(); expires_server_ahead(); expires_server_behind(); expires_extremes(); expires_date_formats(); a_Cookies_set("name=val; expires=\"Sun Jan 10 00:00:00 2038\"", "quoted-date.org", "/", NULL); expect(__LINE__, "Cookie: name=val\r\n", "http", "quoted-date.org", "/"); a_Cookies_set("name=val; expires=\"Sun Jan 11 00:00:00 1970\"", "quoted-pastdate.org", "/", NULL); expect(__LINE__, "", "http", "quoted-pastdate.org", "/"); path(); /* LEADING/TRAILING DOTS AND A LITTLE PUBLIC SUFFIX */ a_Cookies_set("name=val; domain=co.il", "www.co.il", "/", NULL); expect(__LINE__, "", "http", "www.co.il", "/"); a_Cookies_set("name=val; domain=.co.il", "www.co.il", "/", NULL); expect(__LINE__, "", "http", "www.co.il", "/"); a_Cookies_set("name=val; domain=co.il.", "www.co.il.", "/", NULL); expect(__LINE__, "", "http", "www.co.il.", "/"); a_Cookies_set("name=val; domain=.co.il.", "www.co.il.", "/", NULL); expect(__LINE__, "", "http", ".www.co.il.", "/"); a_Cookies_set("name=val; domain=co.org", "www.co.org", "/", NULL); expect(__LINE__, "Cookie: name=val\r\n", "http", "www.co.org", "/"); a_Cookies_set("name=val; domain=.cp.org", "www.cp.org", "/", NULL); expect(__LINE__, "Cookie: name=val\r\n", "http", "www.cp.org", "/"); /* DOTDOMAIN */ a_Cookies_set("name=val; domain=.dotdomain.org", "dotdomain.org", "/", NULL); expect(__LINE__, "Cookie: name=val\r\n", "http", "dotdomain.org", "/"); expect(__LINE__, "Cookie: name=val\r\n", "http", "www.dotdomain.org", "/"); /* HOST_ONLY */ a_Cookies_set("name=val; domain=.hostonly.org", "hostonly.org", "/", NULL); a_Cookies_set("name2=val2", "hostonly.org", "/", NULL); a_Cookies_set("name3=val3; domain=hostonly.org", "hostonly.org", "/", NULL); expect(__LINE__, "Cookie: name=val; name2=val2; name3=val3\r\n", "http", "hostonly.org", "/"); a_Cookies_set("name=new; domain=.hostonly.org", "hostonly.org", "/", NULL); expect(__LINE__, "Cookie: name=new; name2=val2; name3=val3\r\n", "http", "hostonly.org", "/"); a_Cookies_set("name2=new2", "hostonly.org", "/", NULL); expect(__LINE__, "Cookie: name=new; name2=new2; name3=val3\r\n", "http", "hostonly.org", "/"); a_Cookies_set("name3=new3; domain=hostonly.org", "hostonly.org", "/", NULL); expect(__LINE__, "Cookie: name=new; name2=new2; name3=new3\r\n", "http", "hostonly.org", "/"); /* SUBDOMAIN */ a_Cookies_set("name=val; domain=www.subdomain.com", "subdomain.com", "/", NULL); a_Cookies_set("name=val; domain=.www.subdomain.com", "subdomain.com", "/", NULL); expect(__LINE__, "", "http", "subdomain.com", "/"); expect(__LINE__, "", "http", "www.subdomain.com", "/"); /* SUPERDOMAIN(?) */ a_Cookies_set("name=val; domain=.supdomain.com", "www.supdomain.com", "/", NULL); a_Cookies_set("name2=val2; domain=supdomain.com", "www.supdomain.com", "/", NULL); expect(__LINE__, "Cookie: name=val; name2=val2\r\n", "http", "sub2.sub.supdomain.com", "/"); expect(__LINE__, "Cookie: name=val; name2=val2\r\n", "http", "www.supdomain.com", "/"); expect(__LINE__, "Cookie: name=val; name2=val2\r\n", "http", "supdomain.com", "/"); /* UNRELATED */ a_Cookies_set("name=val; domain=another.com", "unrelated.com", "/", NULL); expect(__LINE__, "", "http", "another.com", "/"); a_Cookies_set("name=val; domain=another.com", "a.org", "/", NULL); expect(__LINE__, "", "http", "another.com", "/"); a_Cookies_set("name=val; domain=another.com", "badguys.com", "/", NULL); expect(__LINE__, "", "http", "another.com", "/"); a_Cookies_set("name=val; domain=another.com", "more.badguys.com", "/", NULL); expect(__LINE__, "", "http", "another.com", "/"); a_Cookies_set("name=val; domain=another.com", "verybadguys.com", "/", NULL); expect(__LINE__, "", "http", "another.com", "/"); a_Cookies_set("name=val; domain=similar.com", "imilar.com", "/", NULL); a_Cookies_set("name2=val2; domain=similar.com", "ssimilar.com", "/", NULL); a_Cookies_set("name3=val3; domain=.similar.com", "imilar.com", "/", NULL); a_Cookies_set("name4=val4; domain=.similar.com", "timilar.com", "/", NULL); a_Cookies_set("name4=val4; domain=.similar.com", "tiimilar.com", "/", NULL); expect(__LINE__, "", "http", "similar.com", "/"); /* SECURE */ a_Cookies_set("name=val; secure", "secure.com", "/", NULL); expect(__LINE__, "", "http", "secure.com", "/"); expect(__LINE__, "Cookie: name=val\r\n", "https", "secure.com", "/"); /* HTTPONLY */ a_Cookies_set("name=val; HttpOnly", "httponly.net", "/", NULL); expect(__LINE__, "Cookie: name=val\r\n", "http", "httponly.net", "/"); /* GIBBERISH ATTR IGNORED */ a_Cookies_set("name=val; ldkfals", "gibberish.net", "/", NULL); expect(__LINE__, "Cookie: name=val\r\n", "http", "gibberish.net", "/"); /* WHITESPACE/DELIMITERS */ a_Cookies_set(" name=val ", "whitespace.net", "/", NULL); a_Cookies_set("name2=val2;", "whitespace.net", "/", NULL); expect(__LINE__, "Cookie: name=val; name2=val2\r\n", "http", "whitespace.net", "/"); /* NAMELESS/VALUELESS */ a_Cookies_set("value", "nonameval.org", "/", NULL); a_Cookies_set("name=", "nonameval.org", "/", NULL); a_Cookies_set("name2= ", "nonameval.org", "/", NULL); expect(__LINE__, "Cookie: name=; name2=\r\n", "http", "nonameval.org", "/"); a_Cookies_set("=val2", "nonameval.org", "/", NULL); expect(__LINE__, "Cookie: name=; name2=\r\n", "http", "nonameval.org", "/"); /* SOME IP ADDRS */ a_Cookies_set("name=val", "FEDC:BA98:7654:3210:FEDC:BA98:7654:3210", "/", NULL); expect(__LINE__, "Cookie: name=val\r\n", "http", "FEDC:BA98:7654:3210:FEDC:BA98:7654:3210", "/"); a_Cookies_set("name=val", "::FFFF:129.144.52.38", "/", NULL); expect(__LINE__, "Cookie: name=val\r\n", "http", "::FFFF:129.144.52.38", "/"); a_Cookies_set("name=val", "127.0.0.1", "/", NULL); expect(__LINE__, "Cookie: name=val\r\n", "http", "127.0.0.1", "/"); a_Cookies_set("name=val; domain=128.0.0.1", "128.0.0.1", "/", NULL); expect(__LINE__, "Cookie: name=val\r\n", "http", "128.0.0.1", "/"); a_Cookies_set("name=val; domain=130.0.0.1", "129.0.0.1", "/", NULL); expect(__LINE__, "", "http", "129.0.0.1", "/"); expect(__LINE__, "", "http", "130.0.0.1", "/"); a_Cookies_set("name=val", "2.0.0.1", "/", NULL); a_Cookies_set("name=bad; domain=22.0.0.1", "2.0.0.1", "/", NULL); a_Cookies_set("name=bad; domain=.0.0.1", "2.0.0.1", "/", NULL); a_Cookies_set("name=bad; domain=not-ip.org", "2.0.0.1", "/", NULL); expect(__LINE__, "", "http", "22.0.0.1", "/"); expect(__LINE__, "", "http", "not-ip.org", "/"); expect(__LINE__, "Cookie: name=val\r\n", "http", "2.0.0.1", "/"); #if 0 HAD BEEN PLAYING AROUND WITH REAL PUBLIC SUFFIX a_Cookies_set("name=val;domain=sub.sub.yokohama.jp", "sub.sub.yokohama.jp", "/", NULL); MSG("sub sub yokohama should work: %s\n", a_Cookies_get_query("http", "sub.sub.yokohama.jp", "/")); a_Cookies_set("name=val; domain=sub.tokyo.jp", "sub.sub.tokyo.jp", "/", NULL); MSG("sub tokyo jp should fail: %s\n", a_Cookies_get_query("http", "sub.sub.tokyo.jp", "/")); a_Cookies_set("name=val; domain=pref.chiba.jp", "sub.pref.chiba.jp", "/", NULL); MSG("pref chiba jp should succeed: %s\n", a_Cookies_get_query("http", "sub.pref.chiba.jp", "/")); a_Cookies_set("name=val; domain=org", "www.dillo.org", "/", NULL); a_Cookies_set("name=val; domain=org", "dillo.org", "/", NULL); a_Cookies_set("name=val; domain=org", ".dillo.org", "/", NULL); a_Cookies_set("name=val; domain=org.", ".dillo.org", "/", NULL); a_Cookies_set("name=val; domain=org.", ".dillo.org.", "/", NULL); MSG("org should fail: %s\n", a_Cookies_get_query("http", "www.dillo.org", "/")); #endif MSG("TESTS: passed: %u failed: %u\n", passed, failed); MSG("Now that everything is full of fake cookies, you should run " "'dpidc stop', plus delete cookies.txt if necessary.\n"); return 0; }