diff options
author | Anthony Pesch <inolen@gmail.com> | 2013-08-19 19:12:04 -0700 |
---|---|---|
committer | Anthony Pesch <inolen@gmail.com> | 2013-08-29 01:45:38 -0700 |
commit | f7744fcb18ab5d12c30cf1340c7bacabfc13d1ab (patch) | |
tree | af4b94284ed3b60bd6c685ad9a262a10ed39c8bf /tests/test_sockets.py | |
parent | 54537559f334a916739f8c3f31e94597ad471219 (diff) |
- added raw addr / hostname lookup support
- added getaddrinfo, freeaddrinfo, getnameinfo and gai_strerror stub
- added tests for getaddrinfo and getnameinfo
- consolidated test_gethostbyname and test_sockets_gethostbyname
Diffstat (limited to 'tests/test_sockets.py')
-rw-r--r-- | tests/test_sockets.py | 51 |
1 files changed, 6 insertions, 45 deletions
diff --git a/tests/test_sockets.py b/tests/test_sockets.py index 8f03d6ae..85813447 100644 --- a/tests/test_sockets.py +++ b/tests/test_sockets.py @@ -214,49 +214,14 @@ class sockets(BrowserCore): "0001:0000:0000:0000:0000:0000:ffff:ffff - 1::ffff:ffff\n" ) - def test_gethostbyname(self): - if Settings.USE_TYPED_ARRAYS != 2: return self.skip("assume t2 in gethostbyname") - - src = r''' - #include <netdb.h> - #include <stdio.h> + def test_getaddrinfo(self): + self.do_run(open(path_from_root('tests', 'sockets', 'test_getaddrinfo.c')).read(), 'success') - void test(char *hostname) { - hostent *host = gethostbyname(hostname); - if (!host) { - printf("no such thing\n"); - return; - } - printf("%s : %d : %d\n", host->h_name, host->h_addrtype, host->h_length); - char **name = host->h_aliases; - while (*name) { - printf("- %s\n", *name); - name++; - } - name = host->h_addr_list; - while (name && *name) { - printf("* "); - for (int i = 0; i < host->h_length; i++) - printf("%d.", (*name)[i]); - printf("\n"); - name++; - } - } + def test_getnameinfo(self): + self.do_run(open(path_from_root('tests', 'sockets', 'test_getnameinfo.c')).read(), 'success') - int main() { - test("www.cheezburger.com"); - test("fail.on.this.never.work"); // we will "work" on this - because we are just making aliases of names to ips - test("localhost"); - return 0; - } - ''' - self.do_run(src, '''www.cheezburger.com : 2 : 4 -* -84.29.1.0. -fail.on.this.never.work : 2 : 4 -* -84.29.2.0. -localhost : 2 : 4 -* -84.29.3.0. -''') + def test_gethostbyname(self): + self.do_run(open(path_from_root('tests', 'sockets', 'test_gethostbyname.c')).read(), 'success') def test_sockets_echo(self): sockets_include = '-I'+path_from_root('tests', 'sockets') @@ -300,10 +265,6 @@ localhost : 2 : 4 with harness: self.btest(os.path.join('sockets', 'test_sockets_partial_client.c'), expected='165', args=['-DSOCKK=8995']) - # TODO add support for gethostbyaddr to re-enable this test - # def test_sockets_gethostbyname(self): - # self.btest(os.path.join('sockets', 'test_sockets_gethostbyname.c'), expected='0', args=['-O2', '-DSOCKK=8997']) - def test_sockets_select_server_down(self): for harness in [ WebsockifyServerHarness(os.path.join('sockets', 'test_sockets_select_server_down_server.c'), ['-DSOCKK=9002'], 9003, 9002) |