os: add test for 'Genode::Path'

Issue #5106
This commit is contained in:
Christian Prochaska 2024-02-12 07:39:52 +01:00 committed by Christian Helmuth
parent edba179497
commit 7651c94bf5
10 changed files with 132 additions and 0 deletions

View File

@ -694,6 +694,7 @@ set default_test_pkgs {
test-nic_loopback
test-part_block_gpt
test-part_block_mbr
test-path
test-pipe_read_ready
test-pthread
test-ram_fs_chunk

View File

@ -0,0 +1 @@
'Genode::Path' test

View File

@ -0,0 +1,2 @@
_/src/init
_/src/test-path

View File

@ -0,0 +1 @@
2024-02-08 3f9c9601fd6046b20953830c5290b354711accd7

View File

@ -0,0 +1,52 @@
<runtime ram="10M" caps="100" binary="test-path">
<requires> <timer/> </requires>
<fail after_seconds="10"/>
<succeed>
[init] --- 'Genode::Path' test ---
[init]
[init] testing removal of superfluous slashes
[init]
[init] '//dir1///' -> '/dir1/'
[init]
[init] testing removal of superfluous dot-slashes
[init]
[init] '/./dir1/././' -> '/dir1/'
[init] './dir1/././' -> './dir1/'
[init]
[init] testing removal of double dot dirs
[init]
[init] '/..' -> '/'
[init] '/dir1/..' -> '/'
[init] '/dir1/../..' -> '/'
[init] '/dir1/dir2/..' -> '/dir1'
[init] '/dir1/../dir2' -> '/dir2'
[init] '/../dir1' -> '/dir1'
[init] '/../../dir1' -> '/dir1'
[init] '/../dir1/..' -> '/'
[init] '..' -> ''
[init] 'dir1/..' -> ''
[init] 'dir1/../..' -> ''
[init] 'dir1/dir2/..' -> 'dir1'
[init] 'dir1/../dir2' -> 'dir2'
[init] '../dir1' -> 'dir1'
[init] '../../dir1' -> 'dir1'
[init] '../dir1/..' -> ''
[init]
[init] testing removal of trailing dot
[init]
[init] '/dir1/.' -> '/dir1/'
[init]
[init] --- 'Genode::Path' test finished ---
</succeed>
<content>
<rom label="ld.lib.so"/>
<rom label="test-path"/>
</content>
<config/>
</runtime>

View File

@ -0,0 +1,2 @@
SRC_DIR = src/test/path
include $(GENODE_DIR)/repos/base/recipes/src/content.inc

View File

@ -0,0 +1 @@
2024-02-08 f0e19cf36479e5ab7f6f5cfef1ddc910e6d729e7

View File

@ -0,0 +1,2 @@
base
os

View File

@ -0,0 +1,67 @@
/*
* \brief Tests for the 'Genode::Path' class
* \author Christian Prochaska
* \date 2024-02-08
*/
/*
* Copyright (C) 2024 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#include <base/component.h>
#include <base/log.h>
#include <os/path.h>
using namespace Genode;
void Component::construct(Env &)
{
log("--- 'Genode::Path' test ---");
log("");
log("testing removal of superfluous slashes");
log("");
log("'//dir1///' -> '", Path<16>("//dir1///"), "'");
log("");
log("testing removal of superfluous dot-slashes");
log("");
log("'/./dir1/././' -> '", Path<16>("/./dir1/././"), "'");
log("'./dir1/././' -> '", Path<16>("dir1/././", "./"), "'");
log("");
log("testing removal of double dot dirs");
log("");
log("'/..' -> '", Path<16>("/.."), "'");
log("'/dir1/..' -> '", Path<16>("/dir1/.."), "'");
log("'/dir1/../..' -> '", Path<16>("/dir1/../.."), "'");
log("'/dir1/dir2/..' -> '", Path<16>("/dir1/dir2/.."), "'");
log("'/dir1/../dir2' -> '", Path<16>("/dir1/../dir2"), "'");
log("'/../dir1' -> '", Path<16>("/../dir1"), "'");
log("'/../../dir1' -> '", Path<16>("/../../dir1"), "'");
log("'/../dir1/..' -> '", Path<16>("/../dir1/.."), "'");
log("'..' -> '", Path<16>("", ".."), "'");
log("'dir1/..' -> '", Path<16>("..", "dir1"), "'");
log("'dir1/../..' -> '", Path<16>("../..", "dir1"), "'");
log("'dir1/dir2/..' -> '", Path<16>("dir2/..", "dir1"), "'");
log("'dir1/../dir2' -> '", Path<16>("../dir2", "dir1"), "'");
log("'../dir1' -> '", Path<16>("dir1", ".."), "'");
log("'../../dir1' -> '", Path<16>("../dir1", ".."), "'");
log("'../dir1/..' -> '", Path<16>("dir1/..", ".."), "'");
log("");
log("testing removal of trailing dot");
log("");
log("'/dir1/.' -> '", Path<16>("/dir1/."), "'");
log("");
log("--- 'Genode::Path' test finished ---");
}

View File

@ -0,0 +1,3 @@
TARGET = test-path
SRC_CC = main.cc
LIBS = base