1169d9 | 2004-05-02 | Martin Nilsson | | START_MARKER
|
457cf0 | 2002-11-26 | Martin Nilsson | | dnl tests for file module
|
ab6aec | 1997-02-11 | Fredrik Hübinette (Hubbe) | | test_true(programp(Stdio.File))
test_true(programp(Stdio.File))
|
05c7cd | 1997-07-19 | Fredrik Hübinette (Hubbe) | | test_true(objectp(Stdio.File()))
|
ab6aec | 1997-02-11 | Fredrik Hübinette (Hubbe) | | test_true(programp(Stdio.Port))
|
05c7cd | 1997-07-19 | Fredrik Hübinette (Hubbe) | | test_true(objectp(Stdio.Port()))
|
457cf0 | 2002-11-26 | Martin Nilsson | | test_any(object o; o=Stdio.File(); destruct(o); return 1,1)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
32cc77 | 2004-03-21 | Henrik Grubbström (Grubba) | | dnl - mkdir
test_any([[
Stdio.Stat st = file_stat("/tmp");
string prefix = (st && st->isdir)?"/tmp/":"";
int pid = getpid();
int i;
prefix += "conftest_pike_dir_";
for(i = 0; i < 32; i++) {
string testdir = prefix + i;
|
b521cd | 2015-05-30 | Henrik Grubbström (Grubba) | | rm(testdir);
if (mkdir(testdir) || rm(testdir + "/conftest")) {
|
32cc77 | 2004-03-21 | Henrik Grubbström (Grubba) | | add_constant("testdir", testdir + "/");
add_constant("testfile", testdir + "/conftest");
return 1;
}
}
add_constant("testfile", "conftest");
return 0;
]], 1)
|
457cf0 | 2002-11-26 | Martin Nilsson | | dnl - file->open
dnl - file->close
|
32cc77 | 2004-03-21 | Henrik Grubbström (Grubba) | | test_any(object o=Stdio.File(); return o->open(testfile,"wct") && o->close(),1)
|
768725 | 2008-10-17 | Martin Stjernholm | | test_any([[
Stdio.File o = Stdio.File();
o->open ("file_that_doesnt_exist", "r");
return o->errno();
]], System.ENOENT)
test_any([[
Stdio.File o = Stdio.File();
o->open ("file_in_dir/that_doesnt_exist", "r");
return o->errno();
]], System.ENOENT)
test_any([[
Stdio.File o = Stdio.File();
o->open ("file_with_\fu\n\ny_cha\rs", "r");
return o->errno();
]], System.ENOENT)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
457cf0 | 2002-11-26 | Martin Nilsson | | dnl - file_stat
|
32cc77 | 2004-03-21 | Henrik Grubbström (Grubba) | | test_eq(file_stat(testfile)[1],0)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
457cf0 | 2002-11-26 | Martin Nilsson | | dnl - filesystem_stat
dnl - rm
|
32cc77 | 2004-03-21 | Henrik Grubbström (Grubba) | | test_true(rm(testfile))
test_eq(file_stat(testfile),0)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
457cf0 | 2002-11-26 | Martin Nilsson | | dnl - file->write
|
32cc77 | 2004-03-21 | Henrik Grubbström (Grubba) | | test_any(int e; object o=Stdio.File(); if(!o->open(testfile,"wct")) return "open"+o->errno(); e=o->write("sune"); if(!o->close()) return "close"+o->errno(); return e,4)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
457cf0 | 2002-11-26 | Martin Nilsson | | dnl - file->read
|
32cc77 | 2004-03-21 | Henrik Grubbström (Grubba) | | test_any(string s; object o=Stdio.File(); if(!o->open(testfile,"r")) return "open"+o->errno(); s=o->read(4); if(!o->close()) return "close"+o->errno(); return s,"sune")
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
32cc77 | 2004-03-21 | Henrik Grubbström (Grubba) | | test_any(string s; object o=Stdio.File(); if(!o->open(testfile,"r")) return "open"+o->errno(); s=o->read(999999); if(!o->close()) return "close"+o->errno(); return s,"sune")
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
32cc77 | 2004-03-21 | Henrik Grubbström (Grubba) | | test_any(int e; object o=Stdio.File(); if(!o->open(testfile,"wct")) return "open"+o->errno(); e=o->write(sprintf("%'+-*'100000s","")); if(!o->close()) return "close"+o->errno(); return e,100000)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
32cc77 | 2004-03-21 | Henrik Grubbström (Grubba) | | test_any(string s; object o=Stdio.File(); if(!o->open(testfile,"r")) return "open"+o->errno(); s=o->read(9999999); if(!o->close()) return "close"+o->errno(); return s,sprintf("%'+-*'100000s",""))
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
d644c1 | 2009-03-15 | Martin Stjernholm | | cond_begin([[ Stdio.File()->proxy ]])
|
32cc77 | 2004-03-21 | Henrik Grubbström (Grubba) | | test_any([[string s; object o2,o3,o=Stdio.File(); if(!o->open(testfile,"r")) return "open"+o->errno(); o2=Stdio.File(); o3=o2->pipe(); o2->proxy(o); destruct(o2); s=o3->read(100000); return s]],sprintf("%'+-*'100000s",""))
test_any([[string s; object o2,o3,o=Stdio.File(); if(!o->open(testfile,"r")) return "open"+o->errno(); o2=Stdio.File(); o3=o2->pipe(); o2->proxy(o); destruct(o2); s=o3->read(9999999); return s]],sprintf("%'+-*'100000s",""))
test_any([[string s; object o2,o3,o=Stdio.File(); if(!o->open(testfile,"r")) return "open"+o->errno(); o2=Stdio.File(); o3=o2->pipe(); o2->proxy(o); o2=0; s=o3->read(9999999); return s]],sprintf("%'+-*'100000s",""))
|
d3f6b8 | 1998-05-05 | Fredrik Hübinette (Hubbe) | |
test_any([[
object o2,o=Stdio.File(); o2=o->pipe();
object x2,x=Stdio.File(); x2=x->pipe();
x2->proxy(o);
x2=0;
switch(o2->write("test"))
{
case 4: break;
default: return "Write failed";
case 0: return "Write failed with errno "+o2->errno()+".\n";
}
o2=0;
return x->read() || ("errno:"+x->errno());
]],"test")
test_any([[
object o2,o=Stdio.File(); o2=o->pipe(Stdio.PROP_IPC);
object x2,x=Stdio.File(); x2=x->pipe();
x2->proxy(o);
x2=0;
switch(o2->write("test"))
{
case 4: break;
default: return "Write failed";
case 0: return "Write failed with errno "+o2->errno()+".\n";
}
o2=0;
return x->read() || ("errno:"+x->errno());
]],"test")
test_any([[
object o2,o=Stdio.File(); o2=o->pipe();
object x2,x=Stdio.File(); x2=x->pipe(Stdio.PROP_IPC);
x2->proxy(o);
x2=0;
switch(o2->write("test"))
{
case 4: break;
default: return "Write failed";
case 0: return "Write failed with errno "+o2->errno()+".\n";
}
o2=0;
return x->read() || ("errno:"+x->errno());
]],"test")
test_any([[
object o2,o=Stdio.File(); o2=o->pipe(Stdio.PROP_IPC);
object x2,x=Stdio.File(); x2=x->pipe(Stdio.PROP_IPC);
x2->proxy(o);
x2=0;
switch(o2->write("test"))
{
case 4: break;
default: return "Write failed";
case 0: return "Write failed with errno "+o2->errno()+".\n";
}
o2=0;
return x->read() || ("errno:"+x->errno());
]],"test")
|
d644c1 | 2009-03-15 | Martin Stjernholm | | cond_end // Stdio.File()->proxy
|
d3f6b8 | 1998-05-05 | Fredrik Hübinette (Hubbe) | |
test_any([[object o,o2=Stdio.File(); o=o2->pipe(); destruct(o2); return o->read()]],"")
test_any([[object o,o2=Stdio.File(); o=o2->pipe(); o2=0; return o->read()]],"")
test_any([[object o,o2=Stdio.File(); o=o2->pipe(Stdio.PROP_IPC); destruct(o); return o2->read() || ("error:"+o2->errno())]],"")
test_any([[object o,o2=Stdio.File(); o=o2->pipe(Stdio.PROP_IPC); o=0; return o2->read() || ("error:"+o2->errno())]],"")
|
457cf0 | 2002-11-26 | Martin Nilsson | | dnl - file->seek
dnl - file->tell
|
32cc77 | 2004-03-21 | Henrik Grubbström (Grubba) | | test_any(object o=Stdio.File(); return o->open(testfile,"r") && o->read(4711) && o->tell() == 4711 && o->close(),1)
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
457cf0 | 2002-11-26 | Martin Nilsson | | dnl - file->stat
|
32cc77 | 2004-03-21 | Henrik Grubbström (Grubba) | | test_equal([[Stdio.File(testfile,"r")->stat()[..1]]],[[file_stat(testfile)[..1]]])
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
457cf0 | 2002-11-26 | Martin Nilsson | | dnl - file->errno
test_do(Stdio.File("stdin")->errno())
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
457cf0 | 2002-11-26 | Martin Nilsson | | dnl - file->set_nonblocking
dnl - file->set_blocking
dnl - file->set_id
dnl - file->query_id
test_false(Stdio.File("stdin")->query_id())
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
457cf0 | 2002-11-26 | Martin Nilsson | | dnl - File->query_read_callback
test_do(Stdio.File("stdin")->query_read_callback())
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
457cf0 | 2002-11-26 | Martin Nilsson | | dnl - file->query_write_callback
test_do(Stdio.File("stdin")->query_write_callback())
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
457cf0 | 2002-11-26 | Martin Nilsson | | dnl - file->query_close_callback
test_do(Stdio.File("stdin")->query_close_callback())
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
457cf0 | 2002-11-26 | Martin Nilsson | | dnl - file->open_socket
dnl - file->connect
dnl - file->query_address
dnl - file->pipe
test_any([[object o=Stdio.File(),o2=o->pipe();o->write("1"); return o2->read(1)]],"1")
test_any([[object o=Stdio.File(),o2=o->pipe();o2->write("1"); return o->read(1)]],"1")
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
457cf0 | 2002-11-26 | Martin Nilsson | | dnl - file->dup
|
32cc77 | 2004-03-21 | Henrik Grubbström (Grubba) | | test_any([[object o=Stdio.File(); o->open(testfile,"r"); o=o->dup(); return o->read(100)]] ,sprintf("%'+-*'100s",""))
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
457cf0 | 2002-11-26 | Martin Nilsson | | dnl - file->assign
|
32cc77 | 2004-03-21 | Henrik Grubbström (Grubba) | | test_any([[object o=Stdio.File(),o2=Stdio.File(); o->open(testfile,"r"); o2->assign(o); return o2->read(100)]] ,sprintf("%'+-*'100s",""))
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
457cf0 | 2002-11-26 | Martin Nilsson | | dnl - file->dup2
|
32cc77 | 2004-03-21 | Henrik Grubbström (Grubba) | | test_any([[object o=Stdio.File(),o2=Stdio.File(); o2->pipe(); o->open(testfile,"r"); o->dup2(o2); return o2->read(100)]] ,sprintf("%'+-*'100s",""))
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
a12f27 | 1998-01-10 | Fredrik Hübinette (Hubbe) | | dnl test_eq(Process.popen("echo foo"),"foo\n")
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
457cf0 | 2002-11-26 | Martin Nilsson | | dnl - socket->bind
dnl - socket->set_id
dnl - socket->query_id
dnl - socket->errno
dnl - socket->accept
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | |
|
32cc77 | 2004-03-21 | Henrik Grubbström (Grubba) | | test_true(rm(testfile))
test_eq(file_stat(testfile),0)
test_any(object o=Stdio.File(); return o->open(testfile,"wac") && o->write("x") && o->close(),1)
test_eq(file_stat(testfile)[1],1)
test_any(object o=Stdio.File(); return o->open(testfile,"wa") && o->write("x") && o->close(),1)
test_eq(file_stat(testfile)[1],2)
test_any(object o=Stdio.File(); return o->open(testfile,"wac") && o->write("x") && o->close(),1)
test_eq(file_stat(testfile)[1],3)
test_any(object o=Stdio.File(); return o->open(testfile,"wa") && o->write("x") && o->close(),1)
test_eq(file_stat(testfile)[1],4)
test_any(object o=Stdio.File(); return o->open(testfile,"wa") && o->write("x") && o->close(),1)
test_eq(file_stat(testfile)[1],5)
test_any(object o=Stdio.File(); return o->open(testfile,"war") && o->write("x") && o->close(),1)
test_eq(file_stat(testfile)[1],6)
test_any(object o=Stdio.File(); return o->open(testfile,"wrac") && o->write("x") && o->close(),1)
test_eq(file_stat(testfile)[1],7)
test_any(object o=Stdio.File(); return o->open(testfile,"wac") && o->write("x") && o->close(),1)
test_eq(file_stat(testfile)[1],8)
test_any(object o=Stdio.File(); return o->open(testfile,"wrac") && o->write("x") && o->close(),1)
test_eq(file_stat(testfile)[1],9)
test_any(object o=Stdio.File(); return o->open(testfile,"wrac") && o->write("x") && o->close(),1)
test_eq(file_stat(testfile)[1],10)
test_true(rm(testfile))
test_eq(file_stat(testfile),0)
|
4168fe | 1998-04-24 | Fredrik Hübinette (Hubbe) | |
|
457cf0 | 2002-11-26 | Martin Nilsson | | dnl - file_stat
dnl - perror
dnl - rm
dnl - mkdir
dnl - get_dir
|
b1510a | 2004-10-24 | Martin Nilsson | | test_true(arrayp(get_dir()))
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_true(arrayp(get_dir(".")))
|
457cf0 | 2002-11-26 | Martin Nilsson | | dnl - cd
dnl - getcwd
|
e5bb7d | 1996-09-23 | Fredrik Hübinette (Hubbe) | | test_true(stringp(getcwd()))
|
2201d8 | 1996-10-15 | Fredrik Hübinette (Hubbe) | |
|
457cf0 | 2002-11-26 | Martin Nilsson | | dnl strerror
|
ab6aec | 1997-02-11 | Fredrik Hübinette (Hubbe) | | cond([[all_constants()->strerror]],
|
2201d8 | 1996-10-15 | Fredrik Hübinette (Hubbe) | | [[
|
2ea0e7 | 2000-04-08 | Henrik Grubbström (Grubba) | | test_do(return strerror(1))
|
2201d8 | 1996-10-15 | Fredrik Hübinette (Hubbe) | | test_true(stringp(strerror(2)||""))
]])
|
32cc77 | 2004-03-21 | Henrik Grubbström (Grubba) | | test_do(object o=Stdio.File(); if(!o->open(testfile,"wct")) return -1; o->write("foo\n" * 100); o->close();)
|
f96da0 | 1996-10-24 | Fredrik Hübinette (Hubbe) | |
|
457cf0 | 2002-11-26 | Martin Nilsson | | dnl Stdio.FILE
|
32cc77 | 2004-03-21 | Henrik Grubbström (Grubba) | | test_any([[object o=Stdio.FILE(); o->open(testfile,"r"); return o->gets()]],"foo")
test_any(object o=Stdio.FILE(); o->open(testfile,"r"); return o->gets()+o->gets()+o->gets(),"foofoofoo")
test_any(int e; object o=Stdio.FILE(); o->open(testfile,"r"); for(e=0;e<100;e++) if(o->gets() != "foo") return e; return -1,-1)
|
f96da0 | 1996-10-24 | Fredrik Hübinette (Hubbe) | |
|
ab6aec | 1997-02-11 | Fredrik Hübinette (Hubbe) | | test_true(Stdio.stdin)
test_true(Stdio.stdout)
test_true(Stdio.stderr)
|
f96da0 | 1996-10-24 | Fredrik Hübinette (Hubbe) | |
|
32cc77 | 2004-03-21 | Henrik Grubbström (Grubba) | | test_eq(Stdio.read_file(testfile,0,5), "foo\n"*5)
test_eq(Stdio.read_file(testfile,1,5), "foo\n"*5))
test_eq(Stdio.read_file(testfile,100,5),"")
|
d386e6 | 1998-03-20 | Fredrik Hübinette (Hubbe) | |
|
457cf0 | 2002-11-26 | Martin Nilsson | | dnl locking
|
d644c1 | 2009-03-15 | Martin Stjernholm | | cond_begin([[Stdio.File()->lock]])
|
34965e | 2004-01-02 | Henrik Grubbström (Grubba) | | dnl FIXME: It seems MacOS X has a flock(2) that always fails with ENOTSUP.
|
32cc77 | 2004-03-21 | Henrik Grubbström (Grubba) | | test_true(Stdio.File(testfile,"wr")->lock()&&1)
test_true(Stdio.File(testfile,"wr")->trylock()&&1)
test_true(Stdio.File(testfile,"wr")->trylock()&&1)
|
397b65 | 2000-08-27 | Henrik Grubbström (Grubba) | | test_eval_error([[
|
32cc77 | 2004-03-21 | Henrik Grubbström (Grubba) | | mixed o=Stdio.File(testfile,"wr");
|
1e230a | 2014-09-14 | Stephen R. van den Berg | | object k=o->lock();
|
397b65 | 2000-08-27 | Henrik Grubbström (Grubba) | | o->lock();
]])
test_any([[
|
32cc77 | 2004-03-21 | Henrik Grubbström (Grubba) | | mixed o=Stdio.File(testfile,"wr");
|
397b65 | 2000-08-27 | Henrik Grubbström (Grubba) | | object k = o->lock();
return o->trylock();
]], 0)
|
32cc77 | 2004-03-21 | Henrik Grubbström (Grubba) | | test_true(Stdio.File(testfile,"wr")->lock()&&1)
|
d644c1 | 2009-03-15 | Martin Stjernholm | |
cond_end // Stdio.File()->lock
|
d386e6 | 1998-03-20 | Fredrik Hübinette (Hubbe) | |
|
f53ba3 | 2003-05-14 | Marcus Comstedt | | dnl pty handling
|
0e4920 | 2003-05-15 | Marcus Comstedt | |
cond([[ Stdio.File()->openpt ]],
[[
test_true(Stdio.File()->openpt("rw"));
]])
cond([[ Stdio.File()->openpt && Stdio.File()->grantpt ]],
|
f53ba3 | 2003-05-14 | Marcus Comstedt | | [[
|
0e4920 | 2003-05-15 | Marcus Comstedt | | test_any([[
Stdio.File p = Stdio.File();
return p->openpt("rw") && stringp(p->grantpt());
]], 1)
|
f53ba3 | 2003-05-14 | Marcus Comstedt | | ]])
|
32cc77 | 2004-03-21 | Henrik Grubbström (Grubba) | | test_true(rm(testfile))
test_do(add_constant("testfile"));
cond([[ all_constants()->testdir ]],
[[
test_true(rm(testdir));
test_do(add_constant("testdir"));
]])
|
b294a8 | 1998-04-08 | Fredrik Hübinette (Hubbe) | |
|
2e5db8 | 2004-10-21 | Henrik Grubbström (Grubba) | | define(run_sub_test, [[
|
fb4b0d | 2010-07-11 | Martin Stjernholm | | test_tests([[
array a() {return Tools.Testsuite.run_script ($1);}
]])
|
2e5db8 | 2004-10-21 | Henrik Grubbström (Grubba) | | ]])
|
fb5911 | 2015-02-28 | Arne Goedeke | | define(run_socktest, [[
run_sub_test($1 + ({"SRCDIR/socktest.pike"}))
run_sub_test($1 + ({"-DIPV6", "SRCDIR/socktest.pike"}))
run_sub_test($1 + ({"SRCDIR/socktest.pike", "1"}))
run_sub_test($1 + ({"-DIPV6", "SRCDIR/socktest.pike", "1"}))
run_sub_test($1 + ({"SRCDIR/socktest.pike", "2"}))
run_sub_test($1 + ({"-DIPV6", "SRCDIR/socktest.pike", "2"}))
]])
|
b294a8 | 1998-04-08 | Fredrik Hübinette (Hubbe) | |
|
fb5911 | 2015-02-28 | Arne Goedeke | | run_socktest(({}))
|
59feb5 | 2005-02-22 | Henrik Grubbström (Grubba) | |
|
9d9d90 | 2013-11-03 | Per Hedbor | | cond_begin([[ Pike["SelectBackend"] ]])
|
fb5911 | 2015-02-28 | Arne Goedeke | | run_socktest(({"-DBACKEND=SelectBackend"}))
|
09bfa2 | 2008-06-12 | Henrik Grubbström (Grubba) | |
|
9d9d90 | 2013-11-03 | Per Hedbor | | cond_end
|
09bfa2 | 2008-06-12 | Henrik Grubbström (Grubba) | |
|
d644c1 | 2009-03-15 | Martin Stjernholm | | cond_begin([[ Pike["PollBackend"] ]])
|
fb5911 | 2015-02-28 | Arne Goedeke | | run_socktest(({"-DBACKEND=PollBackend"}))
|
09bfa2 | 2008-06-12 | Henrik Grubbström (Grubba) | |
|
d644c1 | 2009-03-15 | Martin Stjernholm | | cond_end
|
09bfa2 | 2008-06-12 | Henrik Grubbström (Grubba) | |
|
d644c1 | 2009-03-15 | Martin Stjernholm | | cond_begin([[ Pike["PollDeviceBackend"] ]])
|
fb5911 | 2015-02-28 | Arne Goedeke | | run_socktest(({"-DBACKEND=PollDeviceBackend"}))
|
09bfa2 | 2008-06-12 | Henrik Grubbström (Grubba) | |
|
d644c1 | 2009-03-15 | Martin Stjernholm | | cond_end
|
09bfa2 | 2008-06-12 | Henrik Grubbström (Grubba) | |
|
2e5db8 | 2004-10-21 | Henrik Grubbström (Grubba) | | run_sub_test(({"SRCDIR/sendfiletest.pike"}))
|
c3d292 | 2001-04-19 | Mirar (Pontus Hagland) | |
|
2e5db8 | 2004-10-21 | Henrik Grubbström (Grubba) | | run_sub_test(({"-DTEST_NORMAL", "SRCDIR/connecttest.pike"}))
run_sub_test(({"SRCDIR/connecttest.pike"}))
|
f710ae | 2003-03-26 | Martin Stjernholm | |
dnl Stdio.Stat
test_any([[
|
68828f | 2003-03-27 | Martin Stjernholm | | // This actually tests the bignum/64 bit stuff.
|
f710ae | 2003-03-26 | Martin Stjernholm | | Stdio.Stat s = Stdio.Stat();
|
68828f | 2003-03-27 | Martin Stjernholm | | s->size = 0x100000000;
if (s->size != 0x100000000) {
werror ("Note: 64 bit file stats apparently not supported on this system.\n");
return 1;
}
|
f710ae | 2003-03-26 | Martin Stjernholm | | s->size = -0x100000000;
|
68828f | 2003-03-27 | Martin Stjernholm | | return s->size == -0x100000000;
]], 1)
|
3783cd | 2007-06-19 | Martin Stjernholm | |
test_any([[
Stdio.File f = Stdio.File();
return f->query_backend() == Pike.DefaultBackend;
]], 1)
test_any([[
Pike.Backend b = Pike.Backend();
Stdio.File f = Stdio.File();
f->set_backend (b);
return f->query_backend() == b;
]], 1)
test_any([[
Stdio.Port f = Stdio.Port();
return f->query_backend() == Pike.DefaultBackend;
]], 1)
test_any([[
Pike.Backend b = Pike.Backend();
Stdio.Port f = Stdio.Port();
f->set_backend (b);
return f->query_backend() == b;
]], 1)
|
cfa6ca | 2011-10-10 | Martin Stjernholm | |
|
f39e17 | 2012-06-21 | Martin Nilsson | | cond_begin([[ Pike["PollDeviceBackend"] && Pike["PollDeviceBackend"]["HAVE_KQUEUE"] ]])
|
ca6bd0 | 2012-05-01 | Bill Welliver | | run_sub_test(({"SRCDIR/kqueuetest.pike"}))
cond_end
|
cb6501 | 2014-10-01 | Martin Nilsson | | dnl Buffer
|
fbc3bf | 2014-09-08 | Per Hedbor | |
|
cb6501 | 2014-10-01 | Martin Nilsson | | test_equal([[Stdio.Buffer("hej")->read(1)]], "h")
|
fbc3bf | 2014-09-08 | Per Hedbor | |
dnl sscanf
|
cb6501 | 2014-10-01 | Martin Nilsson | | test_equal([[Stdio.Buffer("hej")->sscanf("%3c")]], ({6841706}))
test_equal([[Stdio.Buffer("hej")->match("%3c")]], 6841706)
|
fbc3bf | 2014-09-08 | Per Hedbor | |
test_any([[
int i;
|
cb6501 | 2014-10-01 | Martin Nilsson | | Stdio.Buffer b=Stdio.Buffer("hej hej hej");
|
fbc3bf | 2014-09-08 | Per Hedbor | |
while( array a = b->sscanf( "%*[ ]%[^ ]") )
i+= sizeof(a);
return i;
|
f4c93a | 2014-09-08 | Per Hedbor | | ]], 3)
|
fbc3bf | 2014-09-08 | Per Hedbor | |
dnl range_error
dnl output_to()
dnl input_from
dnl __fd_set_output?
dnl _size_object()
dnl also tests that size is doubled when adding..
|
cb6501 | 2014-10-01 | Martin Nilsson | | test_equal( Stdio.Buffer("hej hej")->_size_object(), 0 );
test_equal( Stdio.Buffer("hej hej")->add("hej")->_size_object(),
Stdio.Buffer("hej hej")->add("foo")->add("bar")->_size_object() )
|
fbc3bf | 2014-09-08 | Per Hedbor | |
dnl sizeof()
|
cb6501 | 2014-10-01 | Martin Nilsson | | test_equal( sizeof(Stdio.Buffer("hej")), sizeof("hej"))
test_equal( sizeof(Stdio.Buffer("ej")->add("alpha")), 7)
test_equal( sizeof(Stdio.Buffer()->sprintf("%4H","hej")), 7)
|
fbc3bf | 2014-09-08 | Per Hedbor | |
dnl create(int)
test_any([[
|
cb6501 | 2014-10-01 | Martin Nilsson | | Stdio.Buffer b = Stdio.Buffer(1024*1024);
|
fbc3bf | 2014-09-08 | Per Hedbor | | if( b->_size_object() != 1024*1024 )
return -1;
for( int i = 0; i<1024/4*1024; i++ )
b->add("test");
if( b->_size_object() != 1024*1024 )
return -2;
|
66ca5c | 2014-10-20 | Per Hedbor | | if( has_index(b,"num_malloc" ) )
{
if( b->num_malloc ) return -3;
if( b->num_move ) return -4;
}
|
fbc3bf | 2014-09-08 | Per Hedbor | | return 1;
]], 1 )
dnl create/add( system.memory )
|
f4c93a | 2014-09-08 | Per Hedbor | | test_any([[
|
fbc3bf | 2014-09-08 | Per Hedbor | | System.Memory a = System.Memory(__FILE__);
System.Memory b = System.Memory(100);
|
cb6501 | 2014-10-01 | Martin Nilsson | | Stdio.Buffer buf = Stdio.Buffer(a);
|
fbc3bf | 2014-09-08 | Per Hedbor | |
if( buf->_size_object() != 0 )
return -1;
buf->add( b );
if( buf->_size_object() < sizeof(a)+sizeof(b) )
return -2;
|
f4c93a | 2014-09-08 | Per Hedbor | | if( !has_suffix((string)buf,"\0"*100) )
|
fbc3bf | 2014-09-08 | Per Hedbor | | return -3;
return 1;
|
f4c93a | 2014-09-08 | Per Hedbor | | ]], 1)
|
fbc3bf | 2014-09-08 | Per Hedbor | |
|
9d3bdd | 2014-10-01 | Martin Nilsson | | dnl create/add( buffer )
|
f4c93a | 2014-09-08 | Per Hedbor | | test_any([[
|
cb6501 | 2014-10-01 | Martin Nilsson | | Stdio.Buffer a = Stdio.Buffer("buffer 1");
Stdio.Buffer b = Stdio.Buffer("buffer 2");
|
fbc3bf | 2014-09-08 | Per Hedbor | |
|
cb6501 | 2014-10-01 | Martin Nilsson | | Stdio.Buffer buf = Stdio.Buffer(a);
|
fbc3bf | 2014-09-08 | Per Hedbor | |
if( buf->_size_object() < sizeof(a) )
return -1;
buf->add( b );
if( buf->_size_object() < sizeof(a)+sizeof(b) )
return -2;
if( (string)buf != "buffer 1buffer 2")
return -3;
return 1;
|
f4c93a | 2014-09-08 | Per Hedbor | | ]], 1)
|
fbc3bf | 2014-09-08 | Per Hedbor | |
dnl add( string.buffer )
|
f4c93a | 2014-09-08 | Per Hedbor | | test_any([[
String.Buffer a = String.Buffer();
String.Buffer b = String.Buffer();
a->add("buffer 1");
b->add("buffer 2");
|
fbc3bf | 2014-09-08 | Per Hedbor | |
|
cb6501 | 2014-10-01 | Martin Nilsson | | Stdio.Buffer buf = Stdio.Buffer(a);
|
fbc3bf | 2014-09-08 | Per Hedbor | |
if( buf->_size_object() < sizeof(a) )
return -1;
buf->add( b );
if( buf->_size_object() < sizeof(a)+sizeof(b) )
return -2;
if( (string)buf != "buffer 1buffer 2")
return -3;
return 1;
|
f4c93a | 2014-09-08 | Per Hedbor | | ]], 1)
|
fbc3bf | 2014-09-08 | Per Hedbor | |
dnl add( string )
|
f4c93a | 2014-09-08 | Per Hedbor | | test_any([[
|
fbc3bf | 2014-09-08 | Per Hedbor | | string a = ("buffer 1");
string b = ("buffer 2");
|
cb6501 | 2014-10-01 | Martin Nilsson | | Stdio.Buffer buf = Stdio.Buffer(a);
|
fbc3bf | 2014-09-08 | Per Hedbor | |
if( buf->_size_object() > 0 )
return -1;
buf->add( b );
if( buf->_size_object() < sizeof(a)+sizeof(b) )
return -2;
if( (string)buf != "buffer 1buffer 2")
return -3;
return 1;
|
f4c93a | 2014-09-08 | Per Hedbor | | ]], 1)
|
fbc3bf | 2014-09-08 | Per Hedbor | |
dnl add( char )
|
f4c93a | 2014-09-08 | Per Hedbor | | test_any([[
|
fbc3bf | 2014-09-08 | Per Hedbor | | string a = ("buffer 1");
|
cb6501 | 2014-10-01 | Martin Nilsson | | Stdio.Buffer buf = Stdio.Buffer(a);
|
fbc3bf | 2014-09-08 | Per Hedbor | |
if( buf->_size_object() > 0 )
return -1;
buf->add( 'b','u','f','f','e','r',' ','2' );
if( buf->_size_object() < sizeof(a)+8 )
return -2;
if( (string)buf != "buffer 1buffer 2")
return -3;
return 1;
|
f4c93a | 2014-09-08 | Per Hedbor | | ]], 1)
|
fbc3bf | 2014-09-08 | Per Hedbor | |
|
f4c93a | 2014-09-08 | Per Hedbor | | dnl add(array( mix ))
test_any([[
|
fbc3bf | 2014-09-08 | Per Hedbor | | System.Memory tst = System.Memory(2);
tst[0] = ' ';
tst[1] = '2';
|
f4c93a | 2014-09-08 | Per Hedbor | | String.Buffer er = String.Buffer();
mixed z = ({
|
cb6501 | 2014-10-01 | Martin Nilsson | | 'b','u','f',Stdio.Buffer("f"),
|
f4c93a | 2014-09-08 | Per Hedbor | | er,
|
fbc3bf | 2014-09-08 | Per Hedbor | | tst
|
f4c93a | 2014-09-08 | Per Hedbor | | });
er->add("er");
|
fbc3bf | 2014-09-08 | Per Hedbor | |
|
cb6501 | 2014-10-01 | Martin Nilsson | | Stdio.Buffer buf = Stdio.Buffer("buffer 1");
|
fbc3bf | 2014-09-08 | Per Hedbor | | if( buf->_size_object() > 0 )
return -1;
|
f4c93a | 2014-09-08 | Per Hedbor | | buf->add( z, 'b','u','f','f',({'e','r',({' '}),'3'}) );
|
fbc3bf | 2014-09-08 | Per Hedbor | |
|
f4c93a | 2014-09-08 | Per Hedbor | | if( buf->_size_object() < 24 )
|
fbc3bf | 2014-09-08 | Per Hedbor | | return -2;
|
f4c93a | 2014-09-08 | Per Hedbor | | if( (string)buf != "buffer 1buffer 2buffer 3")
|
fbc3bf | 2014-09-08 | Per Hedbor | | return -3;
return 1;
|
f4c93a | 2014-09-08 | Per Hedbor | | ]], 1)
|
fbc3bf | 2014-09-08 | Per Hedbor | |
dnl multi add( combo, also sort of a speed test )
dnl will use on average 3Mb RAM
|
f4c93a | 2014-09-08 | Per Hedbor | | test_any([[
String.Buffer two = String.Buffer();
|
fbc3bf | 2014-09-08 | Per Hedbor | | array tst = ({
System.Memory(1),
|
f4c93a | 2014-09-08 | Per Hedbor | | two,
|
fbc3bf | 2014-09-08 | Per Hedbor | | '3',
"4",
|
cb6501 | 2014-10-01 | Martin Nilsson | | Stdio.Buffer("5"),
|
f4c93a | 2014-09-08 | Per Hedbor | | ({ "6", ({'7',"","",""}) }),
|
fbc3bf | 2014-09-08 | Per Hedbor | | });
|
f4c93a | 2014-09-08 | Per Hedbor | | two->add("2");
|
fbc3bf | 2014-09-08 | Per Hedbor | |
int l = 0;
|
cb6501 | 2014-10-01 | Martin Nilsson | | Stdio.Buffer res = Stdio.Buffer();
|
f4c93a | 2014-09-08 | Per Hedbor | | for( int i = 0; i<102*1024; i++ )
|
fbc3bf | 2014-09-08 | Per Hedbor | | {
|
f4c93a | 2014-09-08 | Per Hedbor | | array args = allocate( random(50) );
|
fbc3bf | 2014-09-08 | Per Hedbor | | for( int j=0; j<sizeof( args ); j++ )
{
|
f4c93a | 2014-09-08 | Per Hedbor | | mixed e = random( tst );
if( intp( e ) )
l +=1;
else
l += sizeof( e );
args[j] = e;
|
fbc3bf | 2014-09-08 | Per Hedbor | | }
res->add(@args);
|
f4c93a | 2014-09-08 | Per Hedbor | | if( sizeof( res ) != l )
return ([i:args, "l":l,"sizeof":sizeof(res)]);
|
fbc3bf | 2014-09-08 | Per Hedbor | | }
return 1;
|
f4c93a | 2014-09-08 | Per Hedbor | | ]], 1)
|
fbc3bf | 2014-09-08 | Per Hedbor | |
dnl basic zero-copy check
test_any( [[
|
cb6501 | 2014-10-01 | Martin Nilsson | | Stdio.Buffer i = Stdio.Buffer("zero copy");
|
66ca5c | 2014-10-20 | Per Hedbor | | if( has_index(i,"num_malloc" ) )
if( i->num_malloc ) return -1;
|
fbc3bf | 2014-09-08 | Per Hedbor | | if( i->_size_object() != 0 ) return -2;
i->add(" data goes here");
|
66ca5c | 2014-10-20 | Per Hedbor | | if( has_index(i,"num_malloc" ) )
if( i->num_malloc!= 1 ) return -3;
|
fbc3bf | 2014-09-08 | Per Hedbor | | if( i->_size_object() == 0 ) return -4;
i->read();
if( i->_size_object() == 0 ) return -5;
i->add("zero copy");
|
8c2355 | 2015-07-26 | Henrik Grubbström (Grubba) | |
// NB: This was "string" in previous versions of Stdio.Buffer.
if( !has_value(sprintf("%O",i), "allocated") ) return -6;
|
fbc3bf | 2014-09-08 | Per Hedbor | |
i->add(" indeed"); /* note: shorter than first string. */
|
f4c93a | 2014-09-08 | Per Hedbor | | if( i->_size_object() == 0 ) return -7;
|
fbc3bf | 2014-09-08 | Per Hedbor | |
|
66ca5c | 2014-10-20 | Per Hedbor | | if( has_index(i,"num_malloc" ) )
if( i->num_malloc != 1 ) return -8;
|
f4c93a | 2014-09-08 | Per Hedbor | | /*
|
8c2355 | 2015-07-26 | Henrik Grubbström (Grubba) | | create - no move
|
f4c93a | 2014-09-08 | Per Hedbor | | add - realloc + move
read - no move (buffer now empty)
add - point to str
add - move to malloc arena
add - no move
*/
|
66ca5c | 2014-10-20 | Per Hedbor | | if( has_index(i,"num_malloc" ) )
return i->num_move <= 2;
return 1;
|
f4c93a | 2014-09-08 | Per Hedbor | | ]], 1)
|
fbc3bf | 2014-09-08 | Per Hedbor | |
|
74c410 | 2014-09-14 | Martin Nilsson | | dnl add_int8()
|
fbc3bf | 2014-09-08 | Per Hedbor | |
|
f4c93a | 2014-09-08 | Per Hedbor | | test_any( [[
|
cb6501 | 2014-10-01 | Martin Nilsson | | Stdio.Buffer b = Stdio.Buffer();
|
f4c93a | 2014-09-08 | Per Hedbor | |
for( int i=0; i<255; i++ )
|
74c410 | 2014-09-14 | Martin Nilsson | | b->add_int8( i )->add_int8(~i);
|
f4c93a | 2014-09-08 | Per Hedbor | |
for( int i=0; i<255; i++ )
if( b[i*2] != i || b[i*2+1] != (~i&255))
return -i;
return 1;
]], 1 )
|
5fcfe8 | 2014-09-14 | Stephen R. van den Berg | | dnl add_int16()
|
fbc3bf | 2014-09-08 | Per Hedbor | |
|
9fc2ef | 2014-09-08 | Per Hedbor | | test_any( [[
string ref = "";
|
cb6501 | 2014-10-01 | Martin Nilsson | | Stdio.Buffer b = Stdio.Buffer();
|
9fc2ef | 2014-09-08 | Per Hedbor | |
for( int i=0; i<255; i++ )
{
ref += sprintf("%2c%2c", i, (~i)&0xffff );
|
5fcfe8 | 2014-09-14 | Stephen R. van den Berg | | b->add_int16( i )->add_int16(~i);
|
9fc2ef | 2014-09-08 | Per Hedbor | | if( (string)b != ref ) return ([
"i":i,
"ref":ref,
"b":(string)b
]);
}
return 1;
]], 1 )
|
f4c93a | 2014-09-08 | Per Hedbor | |
|
fbc3bf | 2014-09-08 | Per Hedbor | | dnl add_int32()
|
9fc2ef | 2014-09-08 | Per Hedbor | | test_any( [[
string ref = "";
|
cb6501 | 2014-10-01 | Martin Nilsson | | Stdio.Buffer b = Stdio.Buffer();
|
9fc2ef | 2014-09-08 | Per Hedbor | |
for( int i=0; i<255; i++ )
{
ref += sprintf("%4c%4c", i, (~i)&0xffffffff );
b->add_int32( i )->add_int32(~i);
if( (string)b != ref ) return ([
"i":i,
"ref":ref,
"b":(string)b
]);
}
return 1;
]], 1 )
|
fbc3bf | 2014-09-08 | Per Hedbor | |
dnl add_int( x, bits);
|
9fc2ef | 2014-09-08 | Per Hedbor | | test_any( [[
string ref = "";
|
cb6501 | 2014-10-01 | Martin Nilsson | | Stdio.Buffer b = Stdio.Buffer();
|
9fc2ef | 2014-09-08 | Per Hedbor | |
for( int j=1; j<255; j++ )
{
string fmt = "%"+j+"c";
for( int i=0; i<255; i+=random(10) )
{
ref += sprintf(fmt, i );
b->add_int( i, j );
}
if( (string)b != ref ) return ([
"width":j,
"ref":ref,
"b":(string)b
]);
b->clear();
ref = "";
}
return 1;
]], 1 )
|
fbc3bf | 2014-09-08 | Per Hedbor | | dnl add_int( bignum, bits);
|
9fc2ef | 2014-09-08 | Per Hedbor | | test_any( [[
string ref = "";
|
cb6501 | 2014-10-01 | Martin Nilsson | | Stdio.Buffer b = Stdio.Buffer();
|
9fc2ef | 2014-09-08 | Per Hedbor | |
for( int j=1; j<255; j++ )
{
int i = random((1<<(j*8))-1);
ref += sprintf("%"+j+"c", i );
b->add_int( i, j );
if( (string)b != ref ) return ([
"i":i, "j":j,
"ref":ref,
"b":(string)b
]);
}
return 1;
]], 1 )
dnl add_hstring( str, bytes )
test_error( [[
|
cb6501 | 2014-10-01 | Martin Nilsson | | Stdio.Buffer b = Stdio.Buffer();
|
9fc2ef | 2014-09-08 | Per Hedbor | | b->add_hstring("testing", 0 );
]], 1 )
test_error( [[
|
cb6501 | 2014-10-01 | Martin Nilsson | | Stdio.Buffer b = Stdio.Buffer();
|
9fc2ef | 2014-09-08 | Per Hedbor | | b->add_hstring(" "*256, 1 );
]], 1 )
test_any( [[
|
cb6501 | 2014-10-01 | Martin Nilsson | | array(Stdio.Buffer) b = allocate(10,Stdio.Buffer)();
|
9fc2ef | 2014-09-08 | Per Hedbor | | for( int i = 0; i<1000; i++ )
{
string chunk = " "*random(255);
for( int w = 0; w<9; w++ )
b[w]->add_hstring( chunk, w+1 );
}
for( int i = 0; i<1000; i++ )
{
string chunk = b[0]->read_hstring(1);
for( int w = 1; w<9; w++ )
{
if( b[w]->read_hstring( w+1 ) != chunk )
return ({w+1,strlen(chunk)});
}
}
return 1;
]], 1);
test_any( [[
|
cb6501 | 2014-10-01 | Martin Nilsson | | Stdio.Buffer b = Stdio.Buffer();
|
9fc2ef | 2014-09-08 | Per Hedbor | | b->add( "\0\1" );
if( b->read_hstring( 2 ) )
return -1;
if( sizeof(b) != 2 )
return -2;
b->add("x");
if( b->read_hstring( 2 ) != "x" )
return -3;
return 1;
]], 1);
|
fbc3bf | 2014-09-08 | Per Hedbor | |
dnl add_hstring( obj*, bits )
|
9fc2ef | 2014-09-08 | Per Hedbor | | test_any( [[
|
cb6501 | 2014-10-01 | Martin Nilsson | | array(Stdio.Buffer) b = allocate(10,Stdio.Buffer)();
|
9fc2ef | 2014-09-08 | Per Hedbor | | System.Memory chunk = System.Memory(255);
for( int i = 0; i<1000; i++ )
{
for( int w = 0; w<9; w++ )
b[w]->add_hstring( chunk, w+1 );
}
for( int i = 0; i<1000; i++ )
{
string chunk = b[0]->read_hstring(1);
for( int w = 1; w<9; w++ )
{
if( b[w]->read_hstring( w+1 ) != chunk )
return ({w+1,strlen(chunk)});
}
}
return 1;
]], 1);
|
fbc3bf | 2014-09-08 | Per Hedbor | | dnl add_ints
|
9fc2ef | 2014-09-08 | Per Hedbor | | test_any( [[
array q = allocate(100000,random)(8438439834983948938439849834983498349834983498);
|
cb6501 | 2014-10-01 | Martin Nilsson | | Stdio.Buffer i = Stdio.Buffer();
|
9fc2ef | 2014-09-08 | Per Hedbor | | i->add_ints( q, 20 );
return 1;
]], 1);
test_error( [[
array q = ({8438439834983948938439849834983498349834983498});
|
cb6501 | 2014-10-01 | Martin Nilsson | | Stdio.Buffer i = Stdio.Buffer();
|
9fc2ef | 2014-09-08 | Per Hedbor | | i->add_ints( q, 7 );
return 1;
]], 1);
test_any( [[
array q = ({10,20,30});
|
cb6501 | 2014-10-01 | Martin Nilsson | | Stdio.Buffer i = Stdio.Buffer();
|
9fc2ef | 2014-09-08 | Per Hedbor | | i->add_ints( q, 7 );
return 1;
]], 1);
test_error( [[
array q = ({10,"20",30});
|
cb6501 | 2014-10-01 | Martin Nilsson | | Stdio.Buffer i = Stdio.Buffer();
|
9fc2ef | 2014-09-08 | Per Hedbor | | i->add_ints( q, 7 );
return 1;
]], 1);
test_any( [[
array q = ({10,"20",30});
|
cb6501 | 2014-10-01 | Martin Nilsson | | Stdio.Buffer i = Stdio.Buffer();
|
9fc2ef | 2014-09-08 | Per Hedbor | | catch{i->add_ints( q, 7 );};
if( sizeof(i) )
return -1;
return 1;
]], 1);
|
fbc3bf | 2014-09-08 | Per Hedbor | | dnl lock
dnl cast
dnl indexing
dnl set_error_mode
dnl _sprintf
|
1f2b0e | 2014-11-27 | Henrik Grubbström (Grubba) | | test_any( [[
// Test that _sprintf() doesn't modify the buffer,
// and that the characters are qouted as expected.
//
// NB: The formatting generated by %O is not normative,
// and may change.
Stdio.Buffer buf = Stdio.Buffer("ABC\"\n\0");
return sprintf("%O|%s|%q|%s|%q|%O|", buf, buf, buf, buf, buf, buf) +
(string)buf;
]], "_static_modules._Stdio()->Buffer(6 bytes, read=[..-1] data=[0..5] free=[6..0] string)|"
"ABC\"\n\0|"
"\"ABC\\\"\\n\\0\"|"
"ABC\"\n\0|"
"\"ABC\\\"\\n\\0\"|"
"_static_modules._Stdio()->Buffer(6 bytes, read=[..-1] data=[0..5] free=[6..0] string)|"
"ABC\"\n\0")
|
ca6bd0 | 2012-05-01 | Bill Welliver | |
|
1169d9 | 2004-05-02 | Martin Nilsson | | END_MARKER
|