From 46c65613022be76c938f1541a07dc5552b4b64d2 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Fri, 29 May 2020 22:04:45 +0530 Subject: [PATCH] test/posix: convert to bash script --- tests/posix.dhall | 193 +++++++++++++++++++++++++--------------------- tests/posix.nix | 30 ++++++- 2 files changed, 133 insertions(+), 90 deletions(-) diff --git a/tests/posix.dhall b/tests/posix.dhall index a506b9c..9d48af3 100644 --- a/tests/posix.dhall +++ b/tests/posix.dhall @@ -8,92 +8,113 @@ let Prelude = Genode.Prelude let XML = Prelude.XML -let Child = Genode.Init.Child +let Init = Genode.Init -let toChild = - λ(binary : Text) - → λ(args : List Text) - → { mapKey = binary - , mapValue = - Child.flat - Child.Attributes::{ - , binary = binary - , exitPropagate = True - , resources = Genode.Init.Resources::{ - , caps = 256 - , ram = Genode.units.MiB 4 +let Child = Init.Child + +in λ(params : { bash : Text, coreutils : Text, script : Text }) + → let init = + Init::{ + , verbose = True + , routes = + [ Init.ServiceRoute.parent "Timer" + , Init.ServiceRoute.parent "Rtc" + ] + , children = toMap + { vfs = + Child.flat + Child.Attributes::{ + , binary = "vfs" + , config = Init.Config::{ + , content = + [ Prelude.XML.text + '' + + + + + + + + '' + ] + } + , provides = [ "File_system" ] + , resources = Genode.Init.Resources::{ + , caps = 256 + , ram = Genode.units.MiB 8 + } + , routes = + Prelude.List.map + Text + Init.ServiceRoute.Type + Init.ServiceRoute.parent + [ "File_system", "Rtc" ] + } + , store_rom = + Child.flat + Child.Attributes::{ + , binary = "cached_fs_rom" + , provides = [ "ROM" ] + , resources = Init.Resources::{ + , caps = 256 + , ram = Genode.units.MiB 4 + } + , routes = + [ Init.ServiceRoute.parentLabel + "File_system" + (None Text) + (Some "nix") + ] + } + , shell = + Child.flat + Child.Attributes::{ + , binary = "bash" + , config = Genode.Init.Config::{ + , content = + [ Prelude.XML.text + '' + + + '' + ] + # Prelude.List.map + Text + XML.Type + ( λ(x : Text) + → XML.leaf + { name = "arg" + , attributes = toMap { value = x } + } + ) + [ "bash", params.script ] + } + , exitPropagate = True + , resources = Genode.Init.Resources::{ + , caps = 256 + , ram = Genode.units.MiB 8 + } + , routes = + [ Init.ServiceRoute.child "File_system" "vfs" + , { service = + { name = "ROM" + , label = + Init.LabelSelector.Type.Partial + { prefix = Some "/nix/store/" + , suffix = None Text + } + } + , route = + Init.Route.Type.Child + { name = "store_rom" + , label = None Text + , diag = None Bool + } + } + ] + } } - , config = Genode.Init.Config::{ - , content = - [ Prelude.XML.text - '' - - - - - - Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do - eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad - minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip - ex ea commodo consequat. Duis aute irure dolor in reprehenderit in - voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur - sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt - mollit anim id est laborum. + } - Curabitur pretium tincidunt lacus. Nulla gravida orci a odio. Nullam - varius, turpis et commodo pharetra, est eros bibendum elit, nec luctus - magna felis sollicitudin mauris. Integer in mauris eu nibh euismod - gravida. Duis ac tellus et risus vulputate vehicula. Donec lobortis - risus a elit. Etiam tempor. Ut ullamcorper, ligula eu tempor congue, - eros est euismod turpis, id tincidunt sapien risus a quam. Maecenas - fermentum consequat mi. Donec fermentum. Pellentesque malesuada nulla a - mi. Duis sapien sem, aliquet nec, commodo eget, consequat quis, neque. - Aliquam faucibus, elit ut dictum aliquet, felis nisl adipiscing sapien, - sed malesuada diam lacus eget erat. Cras mollis scelerisque nunc. Nullam - arcu. Aliquam consequat. Curabitur augue lorem, dapibus quis, laoreet - et, pretium ac, nisi. Aenean magna nisl, mollis quis, molestie eu, - feugiat in, orci. In hac habitasse platea dictumst. - - - - - '' - ] - # Prelude.List.map - Text - XML.Type - ( λ(x : Text) - → XML.leaf - { name = "arg", attributes = toMap { value = x } } - ) - ([ binary ] # args) - } - } - } - -let f = λ(binary : Text) → toChild binary ([] : List Text) - -let g = toChild - -in Test::{ - , children = - [ g "hello" [ "--version" ] - , g "b2sum" [ "testdir/testfile" ] - , f "date" - , f "dir" - , f "env" - , g "factor" [ "1337" ] - , g "head" [ "-n", "4", "testdir/testfile" ] - , f "id" - , g "ln" [ "-sv", "testdir/testfile", "tmp/testfile" ] - , g "ls" [ "-l", "-a", "-R" ] - , f "mktemp" - , f "mktemp" - , f "mktemp" - , f "pwd" - , g "seq" [ "3" ] - , g "tail" [ "-n", "4", "testdir/testfile" ] - , g "wc" [ "testdir/testfile" ] - , f "whoami" - ] - } + in Test::{ children = Test.initToChildren init } diff --git a/tests/posix.nix b/tests/posix.nix index a998098..667edac 100644 --- a/tests/posix.nix +++ b/tests/posix.nix @@ -3,10 +3,32 @@ { testEnv, pkgs, legacyPackages, ... }: with pkgs; -testEnv.mkTest rec { +let + inherit (legacyPackages) bash coreutils; + script = with legacyPackages; + writeTextFile { + name = "posix.sh"; + text = '' + export PATH=${ + lib.makeSearchPathOutput "bin" "bin" + (with legacyPackages; [ bash hello coreutils ]) + } + set -v + time ls -lR /nix + sleep 1 + hello -v + sleep 1 + uname -a + ''; + }; +in testEnv.mkTest rec { name = "posix"; - testConfig = ./posix.dhall; - testInputs = map pkgs.genodeSources.depot [ "libc" "posix" ] - ++ (with legacyPackages; [ coreutils hello ]); + testConfig = '' + ${ + ./posix.dhall + } { bash = \"${bash}\", coreutils = \"${coreutils}\", script = \"${script}\" }''; + testInputs = map pkgs.genodeSources.depot [ "libc" "posix" "vfs_pipe" "vfs" ] + ++ [ bash ]; + extraPaths = [ script ] ++ (with legacyPackages; [ coreutils hello ]); meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ehmry ]; }