integrate filedescriptor tests
This commit is contained in:
parent
791f42c104
commit
7a266f22ba
3 changed files with 95 additions and 0 deletions
20
tests/20filedescriptor.tests
Normal file
20
tests/20filedescriptor.tests
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
TESTING "Filedescriptor management" ./test-filedescriptors
|
||||
|
||||
echo testdata > ,tmp_testfile
|
||||
|
||||
TEST "acquire existing file" acquire_existing <<END
|
||||
END
|
||||
|
||||
rm ,tmp_testfile
|
||||
|
||||
|
||||
TEST "acquire file, creating it" acquire_create <<END
|
||||
END
|
||||
|
||||
rm ,tmp_testfile
|
||||
|
||||
TEST "acquire file, creating it, nested dir" acquire_create_dir <<END
|
||||
END
|
||||
|
||||
rm ,tmp_testdir -r
|
||||
|
|
@ -51,6 +51,11 @@ test_references_SOURCES = $(tests_srcdir)/library/test-references.c
|
|||
test_references_CPPFLAGS = $(AM_CPPFLAGS) -std=gnu99 -Wall -Werror -I$(top_srcdir)/src/
|
||||
test_references_LDADD = liblumi.a -lnobugmt -lpthread -ldl -lm -lrt
|
||||
|
||||
check_PROGRAMS += test-filedescriptors
|
||||
test_filedescriptors_SOURCES = $(tests_srcdir)/backend/test-filedescriptors.c
|
||||
test_filedescriptors_CPPFLAGS = $(AM_CPPFLAGS) -std=gnu99 -Wall -Werror -I$(top_srcdir)/src/
|
||||
test_filedescriptors_LDADD = liblumibackend.a liblumi.a -lnobugmt -lpthread -ldl -lm
|
||||
|
||||
#check_PROGRAMS += test-filehandles
|
||||
#test_filehandles_SOURCES = $(tests_srcdir)/backend/test-filehandles.c
|
||||
#test_filehandles_CPPFLAGS = $(AM_CPPFLAGS) -std=gnu99 -Wall -Werror -I$(top_srcdir)/src/
|
||||
|
|
|
|||
70
tests/backend/test-filedescriptors.c
Normal file
70
tests/backend/test-filedescriptors.c
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
test-filedescriptors.c
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2008, Christian Thaeter <ct@pipapo.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include "lib/references.h"
|
||||
#include "lib/safeclib.h"
|
||||
|
||||
#include "backend/filedescriptor.h"
|
||||
|
||||
#include "tests/test.h"
|
||||
|
||||
TESTS_BEGIN
|
||||
|
||||
|
||||
TEST ("acquire_existing")
|
||||
{
|
||||
lumiera_reference descriptor;
|
||||
if (lumiera_filedescriptor_acquire (&descriptor, ",tmp_testfile", LUMIERA_FILE_READONLY))
|
||||
{
|
||||
lumiera_reference_destroy (&descriptor);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
TEST ("acquire_create")
|
||||
{
|
||||
lumiera_reference descriptor;
|
||||
if (lumiera_filedescriptor_acquire (&descriptor, ",tmp_testfile", LUMIERA_FILE_CREATE))
|
||||
{
|
||||
lumiera_reference_destroy (&descriptor);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
TEST ("acquire_create_dir")
|
||||
{
|
||||
lumiera_reference descriptor;
|
||||
if (lumiera_filedescriptor_acquire (&descriptor, ",tmp_testdir/,tmp_testfile", LUMIERA_FILE_CREATE))
|
||||
{
|
||||
lumiera_reference_destroy (&descriptor);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
TESTS_END
|
||||
Loading…
Reference in a new issue