mirror of https://github.com/MidnightCommander/mc
Add test for new ftp parser.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
d4cbed25cc
commit
6cc697beff
|
@ -710,6 +710,7 @@ tests/src/vfs/extfs/Makefile
|
|||
tests/src/vfs/extfs/helpers-list/Makefile
|
||||
tests/src/vfs/extfs/helpers-list/data/config.sh
|
||||
tests/src/vfs/extfs/helpers-list/misc/Makefile
|
||||
tests/src/vfs/ftpfs/Makefile
|
||||
])
|
||||
|
||||
AC_OUTPUT
|
||||
|
|
|
@ -4,3 +4,7 @@ SUBDIRS =
|
|||
if ENABLE_VFS_EXTFS
|
||||
SUBDIRS += extfs
|
||||
endif
|
||||
|
||||
if ENABLE_VFS_FTP
|
||||
SUBDIRS += ftpfs
|
||||
endif
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
PACKAGE_STRING = "/src/vfs/ftpfs"
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
$(GLIB_CFLAGS) \
|
||||
-DTEST_DATA_DIR=\"$(abs_srcdir)/data\" \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/lib/vfs \
|
||||
@CHECK_CFLAGS@
|
||||
|
||||
AM_LDFLAGS = @TESTS_LDFLAGS@
|
||||
|
||||
LIBS = @CHECK_LIBS@ \
|
||||
$(top_builddir)/src/libinternal.la \
|
||||
$(top_builddir)/lib/libmc.la
|
||||
|
||||
if ENABLE_MCLIB
|
||||
LIBS += $(GLIB_LIBS)
|
||||
endif
|
||||
|
||||
EXTRA_DIST = \
|
||||
data/aix_list.input \
|
||||
data/aix_list.output \
|
||||
data/ms_list.input \
|
||||
data/ms_list.output
|
||||
|
||||
TESTS = \
|
||||
ftpfs_parse_long_list
|
||||
|
||||
check_PROGRAMS = $(TESTS)
|
||||
|
||||
ftpfs_parse_long_list_SOURCES = \
|
||||
ftpfs_parse_long_list.c
|
|
@ -0,0 +1,96 @@
|
|||
-rw-rw---- 1 darkna promak 6624 Jun 26 10:21 ${plktmp}ddd
|
||||
-rw-rw---- 1 brydro promak 0 Mar 11 2007 *
|
||||
drwxrws--- 3 promak promak 256 Oct 01 2007 .cpan
|
||||
-rwxr----- 1 promak promak 879 Aug 13 2009 .profile
|
||||
-rw------- 1 promak promak 6344 Jul 05 00:11 .sh_history
|
||||
drwx--S--- 2 promak promak 256 Jan 23 2009 .ssh
|
||||
-rw------- 1 promak promak 277 Jun 30 00:41 .vi_history
|
||||
drwxrwsrwx 21 promak promak 4096 Dec 22 2010 A
|
||||
drwxrws--- 104 promak promak 16384 May 25 20:37 JP
|
||||
drwxrws--- 3 promak promak 4096 Feb 01 14:43 MDM
|
||||
drwx--x--- 2 promak promak 256 Mar 12 2007 Mail
|
||||
drwxrws--- 22 promak promak 4096 Jun 28 18:09 N
|
||||
drwxrws--- 26 promak promak 4096 May 25 23:20 O
|
||||
drwxrws--- 10 promak promak 4096 Jun 21 10:18 PB
|
||||
drwxrws--- 4 promak promak 4096 Aug 12 2009 S
|
||||
drwxr-s--- 13 promak promak 4096 Nov 26 2009 TECH
|
||||
-rw-rw---- 1 matpil promak 0 Jul 05 09:10 TMP_FILED
|
||||
-rw-rw---- 1 promak promak 2808 Sep 05 2011 ala.txt
|
||||
-rw-rw---- 1 promak promak 228 Apr 16 2009 archiwum.log
|
||||
drwxr-s--- 2 promak promak 256 Mar 23 2011 bin
|
||||
-rw-rw---- 1 brydro promak 69 Apr 25 14:23 brydro20120425122315.txt
|
||||
-rw-rw---- 1 darkna promak 0 Jul 03 08:15 core
|
||||
-rw-rw---- 1 promak promak 2664 Jul 31 2007 dupadupa.sql
|
||||
-rwxr-x--- 1 promak promak 7340 Aug 25 2007 dupkop.sh
|
||||
-rw-rw---- 1 promak promak 16365 Jul 19 2010 duppppa
|
||||
drwxr-s--- 2 promak promak 256 Jun 22 2011 err.log
|
||||
-rw-rw---- 1 promak promak 0 Mar 12 2007 err_bkx
|
||||
drwxr-s--- 2 promak promak 4096 Aug 12 2009 etc
|
||||
-rw-rw-r-- 1 promak promak 94 Feb 21 09:18 ftp594398.cfg
|
||||
-rw-r----- 1 promak promak 2855 Apr 22 2009 goenv_arch
|
||||
-rw-r----- 1 promak promak 2875 Aug 12 2009 goenv_nsdr
|
||||
-rw-r----- 1 promak promak 2821 Aug 12 2009 goenv_optksg
|
||||
-rw-r----- 1 promak promak 10691433 Mar 01 14:22 ike.elg
|
||||
-rw-rw---- 1 promak promak 32136 Mar 20 11:14 index.html
|
||||
drwxrws--- 65 promak promak 4096 Mar 01 12:38 jkk
|
||||
-rw-r----- 1 promak promak 55 Feb 22 2011 jkk.awk
|
||||
-rw-rw---- 1 matpil promak 64 Jul 04 19:19 jkk.log
|
||||
-rw-rw---- 1 promak promak 338 Mar 12 2007 jkkver.sh
|
||||
-rw-rw---- 1 matpil promak 12 Jun 13 12:37 jpdatatmp.txt
|
||||
-rw-rw---- 1 promak promak 132 Jun 25 2010 jpsir.log
|
||||
-rw-r----- 1 promak promak 3 Mar 12 2007 koniecstrony
|
||||
-rw-rw-rw- 1 promak promak 64 Jul 04 17:38 ksg_kart_drw.unl
|
||||
-rw-rw---- 1 promak promak 190 Aug 17 2009 ksg_kartpw.test.unl
|
||||
drwxr-s--- 2 promak promak 256 Aug 28 2009 libsh
|
||||
drwxr-xr-x 2 root system 256 Mar 06 2007 lost+found
|
||||
-rw-rw---- 1 matpil promak 69 Mar 27 19:57 matpil20120327175745.txt
|
||||
-rw-rw---- 1 matpil promak 81 May 14 19:57 matpil20120514175733.txt
|
||||
-rw------- 1 promak promak 10743 Aug 13 2009 mbox
|
||||
-rwxr-x--- 1 promak promak 68 Mar 12 2007 odproappl
|
||||
-rw-rw---- 1 promak promak 83 Nov 19 2010 papier_notow.sql
|
||||
-rw-rw-r-- 1 promak promak 1785 Jun 14 2011 plikwyj.txt
|
||||
-rw-r--r-- 1 promak promak 8477579 Jul 02 23:24 proappl.err
|
||||
-rwx------ 1 promak promak 1957 Aug 24 2009 proappl.sh
|
||||
-rwx------ 1 promak promak 674 Mar 12 2007 proappl2f80
|
||||
-rwx------ 1 promak promak 9272 Mar 28 2007 prokop.bkp
|
||||
-rwx------ 1 promak promak 1107611 Jul 04 22:57 prokop.log
|
||||
-rw-r--r-- 1 promak promak 20194873 Jul 04 23:23 prokop.promak
|
||||
-rwxr-x--- 1 promak promak 8769 May 09 18:17 prokop.sh
|
||||
-rwx------ 1 promak promak 8072 Jun 26 2010 prokop.sh.old
|
||||
-rw-r--r-- 1 promak promak 345415 Jun 30 22:25 prokop.wsunle
|
||||
-rwx------ 1 promak promak 6004 Mar 12 2007 prokop2
|
||||
-rwx------ 1 promak promak 6169 Mar 12 2007 prokopF50
|
||||
-rwx------ 1 promak promak 6156 Mar 12 2007 prokopF80
|
||||
-rw-rw---- 1 promak promak 0 Aug 12 2010 promak
|
||||
-rwx------ 1 promak promak 201476 Jul 04 23:06 promak.log
|
||||
-rw-rw---- 1 promak promak 4594135 Aug 12 2009 promak_pliki.txt
|
||||
-rw-r--r-- 1 promak promak 222319 Jul 05 09:05 promonusr.err
|
||||
-rwx------ 1 promak promak 334 Apr 22 2009 promonusr.sh
|
||||
-rw-r--r-- 1 promak promak 7058202 Jul 05 06:07 prostat.err
|
||||
-rwx------ 1 promak promak 525 Sep 19 2009 prostat.sh
|
||||
-rw-r--r-- 1 promak promak 536893 Jul 04 19:15 prowsunle.err
|
||||
-rwx------ 1 promak promak 868 Nov 27 2008 prowsunle.sh
|
||||
-rw-rw---- 1 barros promak 0 Jul 14 2010 salda_z_bazy
|
||||
-rw-rw---- 1 promak promak 1932 Jun 19 13:00 smit.log
|
||||
-rw-rw---- 1 promak promak 908 Jun 19 13:00 smit.script
|
||||
-rw-rw---- 1 promak promak 1174 Jun 19 13:00 smit.transaction
|
||||
-rw-rw-rw- 1 promak promak 613 Jun 20 2011 sqexplain.out
|
||||
-rwxr-xr-x 1 promak promak 45 Mar 12 2007 srozl.sh
|
||||
-rwxr-x--- 1 promak promak 1602 Aug 12 2009 taruj.sh
|
||||
-rw-rw---- 1 darkna promak 1270950 Jan 23 16:41 tax_dznk_nz.unl
|
||||
drwxrws--- 14 promak promak 4096 Aug 04 2009 temp
|
||||
drwxrwx--- 3 promak promak 4096 Mar 23 2011 tmp
|
||||
-rw-rw---- 1 promak promak 75 Jul 22 2010 tmp_drw_pwnul.unl
|
||||
-rw-rw-rw- 1 promak promak 104 Jul 04 17:38 tmp_konta4nik.unl
|
||||
-rw-rw-rw- 1 promak promak 196 Jun 11 09:29 tmpa_drw_portfel09:29:44.774
|
||||
-rw-rw-rw- 1 promak promak 196 Jun 11 09:29 tmpa_drw_portfel09:29:44.967
|
||||
-rw-rw-rw- 1 promak promak 0 Jun 11 09:29 tmpa_drw_portfel_pw09:29:44.774
|
||||
-rw-rw-rw- 1 promak promak 0 Jun 11 09:29 tmpa_drw_portfel_pw09:29:44.967
|
||||
-rw-rw-rw- 1 promak promak 3293 Jun 11 09:29 tmpa_drw_pw09:29:44.774
|
||||
-rw-rw-rw- 1 promak promak 3293 Jun 11 09:29 tmpa_drw_pw09:29:44.967
|
||||
-rwxr-x--- 1 promak promak 1562 Dec 04 2009 ws_go
|
||||
-rwxr-x--- 1 promak promak 406 Aug 14 2009 ws_off
|
||||
-rw-rw---- 1 promak promak 41803 Jun 30 22:13 wsunle.log
|
||||
-rw-r--r-- 1 promak promak 1601 Apr 04 2007 wsunload.err
|
||||
-rw-rw---- 1 promak promak 129 Mar 29 2011 zagraniczne.log
|
||||
-rw-r----- 1 promak promak 57 Mar 12 2007 zrestartuj_informixa
|
|
@ -0,0 +1,96 @@
|
|||
${plktmp}ddd
|
||||
*
|
||||
.cpan
|
||||
.profile
|
||||
.sh_history
|
||||
.ssh
|
||||
.vi_history
|
||||
A
|
||||
JP
|
||||
MDM
|
||||
Mail
|
||||
N
|
||||
O
|
||||
PB
|
||||
S
|
||||
TECH
|
||||
TMP_FILED
|
||||
ala.txt
|
||||
archiwum.log
|
||||
bin
|
||||
brydro20120425122315.txt
|
||||
core
|
||||
dupadupa.sql
|
||||
dupkop.sh
|
||||
duppppa
|
||||
err.log
|
||||
err_bkx
|
||||
etc
|
||||
ftp594398.cfg
|
||||
goenv_arch
|
||||
goenv_nsdr
|
||||
goenv_optksg
|
||||
ike.elg
|
||||
index.html
|
||||
jkk
|
||||
jkk.awk
|
||||
jkk.log
|
||||
jkkver.sh
|
||||
jpdatatmp.txt
|
||||
jpsir.log
|
||||
koniecstrony
|
||||
ksg_kart_drw.unl
|
||||
ksg_kartpw.test.unl
|
||||
libsh
|
||||
lost+found
|
||||
matpil20120327175745.txt
|
||||
matpil20120514175733.txt
|
||||
mbox
|
||||
odproappl
|
||||
papier_notow.sql
|
||||
plikwyj.txt
|
||||
proappl.err
|
||||
proappl.sh
|
||||
proappl2f80
|
||||
prokop.bkp
|
||||
prokop.log
|
||||
prokop.promak
|
||||
prokop.sh
|
||||
prokop.sh.old
|
||||
prokop.wsunle
|
||||
prokop2
|
||||
prokopF50
|
||||
prokopF80
|
||||
promak
|
||||
promak.log
|
||||
promak_pliki.txt
|
||||
promonusr.err
|
||||
promonusr.sh
|
||||
prostat.err
|
||||
prostat.sh
|
||||
prowsunle.err
|
||||
prowsunle.sh
|
||||
salda_z_bazy
|
||||
smit.log
|
||||
smit.script
|
||||
smit.transaction
|
||||
sqexplain.out
|
||||
srozl.sh
|
||||
taruj.sh
|
||||
tax_dznk_nz.unl
|
||||
temp
|
||||
tmp
|
||||
tmp_drw_pwnul.unl
|
||||
tmp_konta4nik.unl
|
||||
tmpa_drw_portfel09:29:44.774
|
||||
tmpa_drw_portfel09:29:44.967
|
||||
tmpa_drw_portfel_pw09:29:44.774
|
||||
tmpa_drw_portfel_pw09:29:44.967
|
||||
tmpa_drw_pw09:29:44.774
|
||||
tmpa_drw_pw09:29:44.967
|
||||
ws_go
|
||||
ws_off
|
||||
wsunle.log
|
||||
wsunload.err
|
||||
zagraniczne.log
|
||||
zrestartuj_informixa
|
|
@ -0,0 +1,11 @@
|
|||
10-15-13 10:08AM <DIR> analytics
|
||||
05-27-14 05:16AM <DIR> aspnet_client
|
||||
11-20-14 12:36PM 161645801 DiscIntercity.tsv
|
||||
11-20-14 12:47PM 2031110 DiscLocal.tsv
|
||||
03-22-15 01:15PM <DIR> INC0023508
|
||||
12-23-14 12:35PM 3403603000 Initial_KPI_20141223_62808477.CSV
|
||||
10-14-13 04:07PM <DIR> segment
|
||||
11-20-14 02:54AM 399282436 SSUnlimAll.tsv
|
||||
10-14-13 04:07PM <DIR> subscriber
|
||||
03-22-15 05:51PM <DIR> tmp
|
||||
11-20-14 11:45AM 773305597 UnlimOnnet.tsv
|
|
@ -0,0 +1,11 @@
|
|||
analytics
|
||||
aspnet_client
|
||||
DiscIntercity.tsv
|
||||
DiscLocal.tsv
|
||||
INC0023508
|
||||
Initial_KPI_20141223_62808477.CSV
|
||||
segment
|
||||
SSUnlimAll.tsv
|
||||
subscriber
|
||||
tmp
|
||||
UnlimOnnet.tsv
|
|
@ -0,0 +1,167 @@
|
|||
/* src/vfs/ftpfs - tests for ftpfs_parse_long_list() function.
|
||||
|
||||
Copyright (C) 2021
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Andrew Borodin <aborodin@vmail.ru>, 2021
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander 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 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "/src/vfs/ftpfs"
|
||||
|
||||
#include "tests/mctest.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "direntry.c"
|
||||
#include "src/vfs/ftpfs/ftpfs_parse_ls.c"
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static struct vfs_s_subclass ftpfs_subclass;
|
||||
static struct vfs_class *me = VFS_CLASS (&ftpfs_subclass);
|
||||
|
||||
static struct vfs_s_super *super;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* @Before */
|
||||
static void
|
||||
setup (void)
|
||||
{
|
||||
vfs_init_subclass (&ftpfs_subclass, "ftpfs", VFSF_NOLINKS | VFSF_REMOTE | VFSF_USETMP, "ftp");
|
||||
|
||||
super = vfs_s_new_super (me);
|
||||
super->name = g_strdup (PATH_SEP_STR);
|
||||
super->root = vfs_s_new_inode (me, super, vfs_s_default_stat (me, S_IFDIR | 0755));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* @After */
|
||||
static void
|
||||
teardown (void)
|
||||
{
|
||||
vfs_s_free_super (me, super);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static GSList *
|
||||
read_list (const char *fname)
|
||||
{
|
||||
FILE *f;
|
||||
char buf[BUF_MEDIUM];
|
||||
GSList *ret = NULL;
|
||||
|
||||
f = fopen (fname, "r");
|
||||
if (f == NULL)
|
||||
return NULL;
|
||||
|
||||
while (fgets (buf, sizeof (buf), f) != NULL)
|
||||
ret = g_slist_prepend (ret, g_strdup (buf));
|
||||
|
||||
fclose (f);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* @DataSource("test_ftpfs_parse_long_list_ds") */
|
||||
/* *INDENT-OFF* */
|
||||
static const struct test_ftpfs_parse_long_list_ds
|
||||
{
|
||||
const char *name;
|
||||
} test_ftpfs_parse_long_list_ds[] =
|
||||
{
|
||||
{ /* 0. Ticket #2841 */
|
||||
"aix"
|
||||
},
|
||||
{ /* 1. Ticket #3174 */
|
||||
"ms"
|
||||
}
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* @Test(dataSource = "test_ftpfs_parse_long_list_ds") */
|
||||
/* *INDENT-OFF* */
|
||||
START_PARAMETRIZED_TEST (test_ftpfs_parse_long_list, test_ftpfs_parse_long_list_ds)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
/* given */
|
||||
char *name;
|
||||
GSList *input, *parsed, *output;
|
||||
GSList *parsed_iter, *output_iter;
|
||||
int err_count;
|
||||
|
||||
/* when */
|
||||
name = g_strdup_printf ("%s/%s_list.input", TEST_DATA_DIR, data->name);
|
||||
input = read_list (name);
|
||||
g_free (name);
|
||||
mctest_assert_not_null (input);
|
||||
|
||||
name = g_strdup_printf ("%s/%s_list.output", TEST_DATA_DIR, data->name);
|
||||
output = read_list (name);
|
||||
g_free (name);
|
||||
mctest_assert_not_null (output);
|
||||
|
||||
parsed = ftpfs_parse_long_list (me, super->root, input, &err_count);
|
||||
|
||||
/* then */
|
||||
for (parsed_iter = parsed, output_iter = output;
|
||||
parsed_iter != NULL && output_iter != NULL;
|
||||
parsed_iter = g_slist_next (parsed_iter), output_iter = g_slist_next (output_iter))
|
||||
mctest_assert_str_eq (VFS_ENTRY (parsed_iter->data)->name, (char *) output_iter->data);
|
||||
|
||||
mctest_assert_null (parsed_iter);
|
||||
mctest_assert_null (output_iter);
|
||||
|
||||
for (parsed_iter = parsed, output_iter = output; parsed_iter != NULL;
|
||||
parsed_iter = g_slist_next (parsed_iter))
|
||||
vfs_s_free_entry (me, VFS_ENTRY (parsed_iter->data));
|
||||
|
||||
g_slist_free (parsed);
|
||||
|
||||
g_slist_free_full (input, g_free);
|
||||
g_slist_free_full (output, g_free);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_PARAMETRIZED_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
TCase *tc_core;
|
||||
|
||||
tc_core = tcase_create ("Core");
|
||||
|
||||
tcase_add_checked_fixture (tc_core, setup, teardown);
|
||||
|
||||
/* Add new tests here: *************** */
|
||||
mctest_add_parameterized_test (tc_core, test_ftpfs_parse_long_list,
|
||||
test_ftpfs_parse_long_list_ds);
|
||||
/* *********************************** */
|
||||
|
||||
return mctest_run_all (tc_core);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
Loading…
Reference in New Issue