# HG changeset patch # User Paul Boddie # Date 1628002616 -7200 # Node ID adeb9552b7555f8d1e61a424477903211576b84e # Parent 3b44f61b63035e955b654bc04ef201818fc65045 Added a test of directory reading in preparation for similar filesystem support. diff -r 3b44f61b6303 -r adeb9552b755 conf/dstest_host_readdir.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/conf/dstest_host_readdir.cfg Tue Aug 03 16:56:56 2021 +0200 @@ -0,0 +1,23 @@ +-- vim:set ft=lua: + +local L4 = require("L4"); + +local l = L4.default_loader; + +local server = l:new_channel(); + +l:startv({ + caps = { + server = server:svr(), + }, + log = { "server", "r" }, + }, + "rom/dstest_host_server", "10"); + +l:startv({ + caps = { + server = server, + }, + log = { "client", "g" }, + }, + "rom/dstest_host_readdir", "rom"); diff -r 3b44f61b6303 -r adeb9552b755 conf/dstest_host_readdir.list --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/conf/dstest_host_readdir.list Tue Aug 03 16:56:56 2021 +0200 @@ -0,0 +1,25 @@ +entry dstest_host_readdir +roottask moe rom/dstest_host_readdir.cfg +module dstest_host_readdir.cfg +module l4re +module ned +module dstest_host_readdir +module dstest_host_server +module lib4re-c.so +module lib4re-c-util.so +module lib4re.so +module lib4re-util.so +module libc_be_l4refile.so +module libc_be_l4re.so +module libc_be_socket_noop.so +module libc_support_misc.so +module libdl.so +module libipc.so +module libl4sys-direct.so +module libl4sys.so +module libl4util.so +module libld-l4.so +module libpthread.so +module libstdc++.so +module libsupc++.so +module libuc_c.so diff -r 3b44f61b6303 -r adeb9552b755 tests/Makefile --- a/tests/Makefile Tue Aug 03 00:05:43 2021 +0200 +++ b/tests/Makefile Tue Aug 03 16:56:56 2021 +0200 @@ -6,6 +6,7 @@ dstest_ext2fs_client \ dstest_file_client \ dstest_host_client \ + dstest_host_readdir \ dstest_pipe_client \ dstest_test_client @@ -21,6 +22,8 @@ SRC_CC_dstest_host_client = dstest_host_client.cc +SRC_CC_dstest_host_readdir = dstest_host_readdir.cc + SRC_CC_dstest_pipe_client = dstest_pipe_client.cc SRC_CC_dstest_test_client = dstest_test_client.cc diff -r 3b44f61b6303 -r adeb9552b755 tests/dstest_host_readdir.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/dstest_host_readdir.cc Tue Aug 03 16:56:56 2021 +0200 @@ -0,0 +1,56 @@ +/* + * Test directory reading. + * + * Copyright (C) 2021 Paul Boddie + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA + */ + +#include +#include + + + +int main(int argc, char *argv[]) +{ + if (argc < 2) + { + printf("Need directory name.\n"); + return 1; + } + + /* Obtain directory name. */ + + char *filename = argv[1]; + DIR *dir = opendir(filename); + + if (dir == NULL) + { + printf("Could not obtain directory: %s\n", filename); + return 1; + } + + struct dirent *dirent; + + while ((dirent = readdir(dir)) != NULL) + printf("> %s\n", dirent->d_name); + + printf("Directory shown.\n"); + + return 0; +} + +// vim: tabstop=2 expandtab shiftwidth=2