This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
|
|
@ -0,0 +1,2 @@
|
|||
# Initial run of ocamlformat
|
||||
9509955118fb10a12b6d968acac271bcd4329b7d
|
||||
36
unikernel/duniverse/mirage-bootvar/.github/workflows/test.yml
vendored
Normal file
36
unikernel/duniverse/mirage-bootvar/.github/workflows/test.yml
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
name: Optional dependencies (mirage-xen mirage-solo5)
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
name: Tests
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
ocaml-version: ["4.14.2"]
|
||||
operating-system: [ubuntu-latest]
|
||||
|
||||
runs-on: ${{ matrix.operating-system }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Use OCaml ${{ matrix.ocaml-version }}
|
||||
uses: ocaml/setup-ocaml@v2
|
||||
with:
|
||||
ocaml-compiler: ${{ matrix.ocaml-version }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: opam install --deps-only -t .
|
||||
|
||||
- name: Install optional dependencies
|
||||
run: opam install mirage-solo5 mirage-xen
|
||||
|
||||
- name: Build
|
||||
run: opam exec -- dune build @all
|
||||
|
||||
- name: Test
|
||||
run: opam exec -- dune runtest
|
||||
4
unikernel/duniverse/mirage-bootvar/.ocamlformat
Normal file
4
unikernel/duniverse/mirage-bootvar/.ocamlformat
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
version = 0.26.2
|
||||
profile = conventional
|
||||
break-infix = fit-or-vertical
|
||||
parse-docstrings = true
|
||||
8
unikernel/duniverse/mirage-bootvar/AUTHORS
Normal file
8
unikernel/duniverse/mirage-bootvar/AUTHORS
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
Anil Madhavapeddy
|
||||
Dan Williams
|
||||
Hannes Mehnert
|
||||
Jon Ludlam
|
||||
Magnus Skjegstad
|
||||
Martin Lucina
|
||||
Mindy Preston
|
||||
Thomas Gazagnaire
|
||||
132
unikernel/duniverse/mirage-bootvar/CHANGES.md
Normal file
132
unikernel/duniverse/mirage-bootvar/CHANGES.md
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
## v1.0.1 2024-05-20
|
||||
|
||||
* Prefix all modules (backend / parse_argv) with Mirage_bootvar to avoid
|
||||
potential conflicts (#2 @hannesm) -- observed while building
|
||||
qubes-mirage-firewall which also depends on mirage-net-xen which provides
|
||||
a module named Backend.
|
||||
|
||||
## v1.0.0 2024-05-16
|
||||
|
||||
* parse-argv, mirage-bootvar-unix, mirage-bootvar-solo5, and mirage-bootvar-xen
|
||||
have been merged into the single mirage-bootvar package. This uses dune
|
||||
variants to select the concrete implementation. The selection is done by
|
||||
the mirage tool which inspects the "target" option in `mirage configure`
|
||||
and outputs the desired ocamlfind sublibrary into the dune.build file.
|
||||
* The main logic is provided by the Mirage_bootvar module, while the
|
||||
implementation to retrieve the boot parameters is provided by the dune variant
|
||||
backend, and implemented by mirage-bootvar.unix, mirage-bootvar.solo5, and
|
||||
mirage-bootvar.xen #1
|
||||
|
||||
## v0.3.0 (parse-argv) 2023-05-22
|
||||
|
||||
* remove build directive on dune dependency (mirage/parse-argv#8 @CraigFE)
|
||||
* remove astring dependency, simplify code (mirage/parse-argv#10 @hannesm)
|
||||
|
||||
## v0.8.0 (mirage-bootvar-xen) 2020-10-21
|
||||
|
||||
* Adapt to mirage-xen 6.0.0 changes (Solo5 based Xen PVH, mirage/mirage-bootvar-xen#45 @mato)
|
||||
|
||||
## v0.7.0 (mirage-bootvar-xen) 2019-11-01
|
||||
|
||||
* Adapt to mirage-xen 5.0.0 changes (mirage/mirage-bootvar-xen#42 @dinosaure)
|
||||
* Require OCaml 4.06.0 now (mirage/mirage-bootvar-xen#43 @hannesm)
|
||||
|
||||
## v0.6.0 (mirage-bootvar-solo5) 2019-09-24
|
||||
|
||||
* Bump version number and dependencies to stay in sync with other Mirage/Solo5
|
||||
components.
|
||||
* Update Travis Matrix, bump to Ubuntu Xenial, only test with last three
|
||||
compiler versions.
|
||||
* Port to dune (mirage/mirage-bootvar-solo5#13, @pascutto)
|
||||
|
||||
## v0.6.0 (mirage-bootvar-xen) 2019-06-17
|
||||
|
||||
* Port to dune from jbuilder (mirage/mirage-bootvar-xen#38 @TheLortex @avsm)
|
||||
* Adapt to mirage-xen 4.0.0 `Os_xen` interface (mirage/mirage-bootvar-xen#37 @TheLortex)
|
||||
* Update Travis to test 4.06 as well (@avsm).
|
||||
|
||||
## v0.2.0 (parse-argv) 2019-03-29
|
||||
|
||||
* port to dune (mirage/parse-argv#7 @hannesm)
|
||||
* do not use the Result module any more (mirage/parse-argv#5 @hannesm)
|
||||
* update to opam 2 metadata (mirage/parse-argv#7 @hannesm)
|
||||
|
||||
## 0.1.0 (mirage-bootvar-unix) 2018-10-29
|
||||
|
||||
Initial release
|
||||
|
||||
## v0.3.0 (mirage-bootvar-solo5) 2018-06-17
|
||||
|
||||
* Adapt to Solo5 v0.3.0 APIs.
|
||||
|
||||
## v0.1.0 (parse-argv) 2017-07-13
|
||||
|
||||
* Port to Jbuilder
|
||||
|
||||
## v0.5.0 (mirage-bootvar-xen) 2017-07-12
|
||||
|
||||
* Port to jbuilder and modernise test matrix.
|
||||
|
||||
## v0.4.0 (mirage-bootvar-xen) 2017-01-20
|
||||
|
||||
* Remove examples directory, as the module is now directly used by the mirage front-end tool.
|
||||
* Add an optional `filter` parameter to `argv`, allowing users to only pass those arguments which cmdliner might expect to see.
|
||||
* Convert to topkg.
|
||||
* Change name to mirage-bootvar-xen from mirage-bootvar.
|
||||
* Move argv parsing to external library `parse_argv` and depend on that library.
|
||||
* Build against MirageOS version 3, and drop support for earlier MirageOS versions.
|
||||
|
||||
## v0.2.0 (mirage-bootvar-solo5) 2017-01-17
|
||||
|
||||
* Port to topkg (@hannesm, mirage/mirage-bootvar-solo5#6)
|
||||
* Use common parse-argv library (@yomimono, mirage/mirage-bootvar-solo5#4)
|
||||
|
||||
## v0.0.3 (parse-argv) 2016-11-07
|
||||
|
||||
* Compile using `debug`to get backtraces.
|
||||
* Improve ocamldoc.
|
||||
* Do not shadow Result.t on older compilers to avoid warning.
|
||||
* Add the `build` shell script into dev repo for convenience.
|
||||
|
||||
## v0.0.2 (parse-argv) 2016-10-20
|
||||
|
||||
* support OCaml version 4.02.3 in addition to 4.03.0
|
||||
|
||||
## v0.0.1 (parse-argv) 2016-10-13
|
||||
|
||||
* initial release of independent parse-argv library (previously in mirage-bootvar-xen, mirage-bootvar-solo5)
|
||||
|
||||
## v0.3.2 (mirage-bootvar-xen) 2016-06-09
|
||||
|
||||
* Use astring instead of re.str (mirage/mirage-bootvar-xen#18 by @jonludlam)
|
||||
* Improve the parser to handle quoted strings and escaped characters; skip arguments that don't conform to 'a=b' rather than dying (mirage/mirage-bootvar-xen#18 by @jonludlam)
|
||||
|
||||
## 0.3.1 (mirage-bootvar-xen) 2016-02-07
|
||||
|
||||
* Fall back to reading `OS.Start_info` if cmdline is not found in Xenstore (mirage/mirage-bootvar-xen#13, by @jonludlam)
|
||||
* Include the string in error message for malformed variables (mirage/mirage-bootvar-xen#11, by @talex5)
|
||||
* Enable warnings and remove an unused `Re` import (mirage/mirage-bootvar-xen#11, by @talex5)
|
||||
* Add travis.yml to Github repo (mirage/mirage-bootvar-xen#12)
|
||||
|
||||
## v0.1.1 (mirage-bootvar-solo5) 2015-07-15
|
||||
|
||||
* Initial release for Solo5, derived from mirage-bootvar-xen.
|
||||
* Only implements the Bootvar.argv interface as nothing else is required by
|
||||
current Mirage.
|
||||
|
||||
## 0.3 (mirage-boovar-xen) 2015-09-15
|
||||
|
||||
* Add `Bootvar.parameters` to export the boot paramters (mirage/mirage-bootvar-xen#5, by @Drup)
|
||||
* Add `Bootvar.argv`, which reformat `Bootvar.parameters` to emulates
|
||||
Sys.argv. (mirage/mirage-bootvar-xen#7, by @Drup)
|
||||
|
||||
## 0.2 (mirage-bootvar-xen) 2015-03-19
|
||||
|
||||
* get no longer raises exception
|
||||
* add get_exn which raises Parameter_not_found on error
|
||||
* return 'Ok of t | 'Error of msg in create instead of raising exception on error
|
||||
* remove debug output
|
||||
|
||||
## 0.1 (mirage-bootvar-xen) 2015-03-19
|
||||
|
||||
* Initial release
|
||||
14
unikernel/duniverse/mirage-bootvar/LICENSE.md
Normal file
14
unikernel/duniverse/mirage-bootvar/LICENSE.md
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
Copyright (c) 2014 Authors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
33
unikernel/duniverse/mirage-bootvar/README.md
Normal file
33
unikernel/duniverse/mirage-bootvar/README.md
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# mirage-bootvar
|
||||
|
||||
An OCaml library to read MirageOS unikernel boot parameters for different
|
||||
targets.
|
||||
|
||||
This package contains the variant Mirage_bootvar.mli with the single
|
||||
function `argv` which returns the array of boot parameters. Implementations
|
||||
of this function for Xen, Solo5, and Unix targets are provided as well.
|
||||
|
||||
Since on some targets, the boot parameters are flattened to a single string,
|
||||
there is no support for whitespaces.
|
||||
|
||||
## Installation
|
||||
|
||||
You can use opam to install mirage-bootvar:
|
||||
|
||||
`opam install mirage-bootvar`
|
||||
|
||||
## History
|
||||
|
||||
This repository originates from four git repositories:
|
||||
- [parse-argv](https://github.com/mirage/parse-argv)
|
||||
- [mirage-bootvar-unix](https://github.com/mirage/mirage-bootvar-unix)
|
||||
- [mirage-bootvar-xen](https://github.com/mirage/mirage-bootvar-xen)
|
||||
- [mirage-bootvar-solo5](https://github.com/mirage/mirage-bootvar-solo5)
|
||||
|
||||
In May 2024, this was consolidated into a single git repository using dune
|
||||
variants.
|
||||
|
||||
## License
|
||||
|
||||
The code is licensed under the ISC license. See LICENSE.md and AUTHORS for
|
||||
further information.
|
||||
3
unikernel/duniverse/mirage-bootvar/dune-project
Normal file
3
unikernel/duniverse/mirage-bootvar/dune-project
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(lang dune 2.6)
|
||||
(name mirage-bootvar)
|
||||
(version v1.0.1)
|
||||
12
unikernel/duniverse/mirage-bootvar/lib/dune
Normal file
12
unikernel/duniverse/mirage-bootvar/lib/dune
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
(library
|
||||
(name mirage_bootvar)
|
||||
(public_name mirage-bootvar)
|
||||
(modules mirage_bootvar)
|
||||
(libraries mirage-bootvar.parse-argv mirage-bootvar.backend))
|
||||
|
||||
(library
|
||||
(name mirage_bootvar_backend)
|
||||
(modules mirage_bootvar_backend)
|
||||
(public_name mirage-bootvar.backend)
|
||||
(default_implementation mirage-bootvar.unix)
|
||||
(virtual_modules mirage_bootvar_backend))
|
||||
22
unikernel/duniverse/mirage-bootvar/lib/mirage_bootvar.ml
Normal file
22
unikernel/duniverse/mirage-bootvar/lib/mirage_bootvar.ml
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
(*
|
||||
* Copyright (c) 2016 mirage-bootvar AUTHORS
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
*)
|
||||
|
||||
let argv () =
|
||||
let cmdline = Mirage_bootvar_backend.cmd_line () in
|
||||
match Mirage_bootvar_parse_argv.(parse cmdline) with
|
||||
| Ok l -> Array.of_list ("mirage" :: l)
|
||||
| Error s -> failwith s
|
||||
19
unikernel/duniverse/mirage-bootvar/lib/mirage_bootvar.mli
Normal file
19
unikernel/duniverse/mirage-bootvar/lib/mirage_bootvar.mli
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
(*
|
||||
* Copyright (c) 2016 mirage-bootvar AUTHORS
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
*)
|
||||
|
||||
val argv : unit -> string array
|
||||
(** Return an argv-like structure. *)
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
(*
|
||||
* Copyright (c) 2016 mirage-bootvar AUTHORS
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
*)
|
||||
|
||||
val cmd_line : unit -> string
|
||||
(** Return the command line passed to the unikernel. This does not include the
|
||||
binary name. *)
|
||||
42
unikernel/duniverse/mirage-bootvar/mirage-bootvar.opam
Normal file
42
unikernel/duniverse/mirage-bootvar/mirage-bootvar.opam
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
version: "1.0.1"
|
||||
opam-version: "2.0"
|
||||
name: "parse-argv"
|
||||
maintainer: "MirageOS Core team"
|
||||
authors: [
|
||||
"Anil Madhavapeddy"
|
||||
"Dan Williams"
|
||||
"Hannes Mehnert"
|
||||
"Jon Ludlam"
|
||||
"Magnus Skjegstad"
|
||||
"Martin Lucina"
|
||||
"Mindy Preston"
|
||||
"Thomas Gazagnaire"
|
||||
]
|
||||
tags: "org:mirage"
|
||||
homepage: "https://github.com/mirage/mirage-bootvar"
|
||||
doc: "https://mirage.github.io/mirage-bootvar/"
|
||||
bug-reports: "https://github.com/mirage/mirage-bootvar/issues"
|
||||
license: "ISC"
|
||||
depends: [
|
||||
"ocaml" {>= "4.08.0"}
|
||||
"dune" {>= "2.6"}
|
||||
"ounit2" {with-test}
|
||||
]
|
||||
depopts: [
|
||||
"mirage-xen"
|
||||
"mirage-solo5"
|
||||
]
|
||||
conflicts: [
|
||||
"mirage-xen" {< "6.0.0"}
|
||||
"mirage-solo5" {< "0.6.0"}
|
||||
]
|
||||
build: [
|
||||
["dune" "subst"] {dev}
|
||||
["dune" "build" "-p" name "-j" jobs]
|
||||
["dune" "runtest" "-p" name "-j" jobs] {with-test}
|
||||
]
|
||||
dev-repo: "git+https://github.com/mirage/mirage-bootvar.git"
|
||||
synopsis: "Boot time arguments for MirageOS"
|
||||
description: """
|
||||
Mirage-bootvar reads and parses boot parameters for MirageOS unikernels.
|
||||
"""
|
||||
3
unikernel/duniverse/mirage-bootvar/parse_argv/dune
Normal file
3
unikernel/duniverse/mirage-bootvar/parse_argv/dune
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(library
|
||||
(name mirage_bootvar_parse_argv)
|
||||
(public_name mirage-bootvar.parse-argv))
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
(*
|
||||
* Copyright (c) mirage-bootvar AUTHORS
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
*)
|
||||
|
||||
(* Split string into whitespace-separated substrings,
|
||||
taking into account quoting *)
|
||||
|
||||
type state = Quoted_escaped | Quoted | Escaped | Normal
|
||||
|
||||
let chars_to_str = function
|
||||
| [] -> []
|
||||
| chars ->
|
||||
let chars = List.rev chars in
|
||||
[ String.init (List.length chars) (List.nth chars) ]
|
||||
|
||||
let parse s =
|
||||
let l = String.length s in
|
||||
let rec loop acc curr state idx =
|
||||
if idx = l then
|
||||
if state = Normal then Ok (List.rev (chars_to_str curr @ acc))
|
||||
else Error "bad input line - either escaped or quoted or both"
|
||||
else
|
||||
match (state, String.unsafe_get s idx) with
|
||||
| Normal, ' ' -> loop (chars_to_str curr @ acc) [] state (idx + 1)
|
||||
| Escaped, c -> loop acc (c :: curr) Normal (idx + 1)
|
||||
| Quoted_escaped, c -> loop acc (c :: curr) Quoted (idx + 1)
|
||||
| Quoted, '\\' -> loop acc curr Quoted_escaped (idx + 1)
|
||||
| Quoted, '"' -> loop acc curr Normal (idx + 1)
|
||||
| Quoted, c -> loop acc (c :: curr) Quoted (idx + 1)
|
||||
| Normal, '\\' -> loop acc curr Escaped (idx + 1)
|
||||
| Normal, '"' -> loop acc curr Quoted (idx + 1)
|
||||
| Normal, c -> loop acc (c :: curr) Normal (idx + 1)
|
||||
in
|
||||
loop [] [] Normal 0
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
(* Copyright (c) mirage-bootvar AUTHORS
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *)
|
||||
|
||||
(** Module to parse a Unix-style argv into a list of strings *)
|
||||
|
||||
val parse : string -> (string list, string) result
|
||||
(** [parse t] will split the [t] string into whitespace-separated substrings,
|
||||
taking into account quoting using the backslash character. *)
|
||||
6
unikernel/duniverse/mirage-bootvar/solo5/dune
Normal file
6
unikernel/duniverse/mirage-bootvar/solo5/dune
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(library
|
||||
(name mirage_bootvar_solo5)
|
||||
(public_name mirage-bootvar.solo5)
|
||||
(libraries mirage-solo5)
|
||||
(implements mirage_bootvar_backend)
|
||||
(optional))
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
(*
|
||||
* Copyright (c) mirage-bootvar AUTHORS
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
*)
|
||||
external cmd_line : unit -> string = "mirage_solo5_get_cmdline"
|
||||
3
unikernel/duniverse/mirage-bootvar/test/dune
Normal file
3
unikernel/duniverse/mirage-bootvar/test/dune
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(test
|
||||
(name test)
|
||||
(libraries ounit2 mirage-bootvar.parse-argv))
|
||||
71
unikernel/duniverse/mirage-bootvar/test/test.ml
Normal file
71
unikernel/duniverse/mirage-bootvar/test/test.ml
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
(*
|
||||
* Copyright (c) 2016 Citrix Systems Inc
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
*)
|
||||
|
||||
open OUnit
|
||||
|
||||
let verbose = ref false
|
||||
|
||||
let log =
|
||||
Printf.ksprintf (fun s -> if !verbose then Printf.fprintf stdout "%s\n%!" s)
|
||||
|
||||
let tests =
|
||||
[
|
||||
("foo bar baz", [ "foo"; "bar"; "baz" ]);
|
||||
({|foo "bar" baz|}, [ "foo"; "bar"; "baz" ]);
|
||||
({|f\ oo b\"r baz|}, [ "f oo"; "b\"r"; "baz" ]);
|
||||
({|foo bar"bie"boo baz|}, [ "foo"; "barbieboo"; "baz" ]);
|
||||
({|foo "bar baz"|}, [ "foo"; "bar baz" ]);
|
||||
({|foo bar\ baz|}, [ "foo"; "bar baz" ]);
|
||||
(" ", []);
|
||||
]
|
||||
|
||||
let test_parse () =
|
||||
let tostr l =
|
||||
String.concat "," (List.map (fun x -> Printf.sprintf "'%s'" x) l)
|
||||
in
|
||||
List.iter
|
||||
(fun (input, expected) ->
|
||||
log "checking '%s'" input;
|
||||
match Mirage_bootvar_parse_argv.parse input with
|
||||
| Error e ->
|
||||
Printf.eprintf "Error - failed to parse: %s (input %s) " e input
|
||||
| Ok l ->
|
||||
if l <> expected then
|
||||
Printf.fprintf stderr
|
||||
"Error - failed to parse. Got:\n%s\nExpected\n%s\n" (tostr l)
|
||||
(tostr expected);
|
||||
assert (l = expected))
|
||||
tests
|
||||
|
||||
let negative_test () =
|
||||
let str = " \\" in
|
||||
log "Testing parse of %s (should fail)" str;
|
||||
match Mirage_bootvar_parse_argv.parse str with
|
||||
| Ok _ -> assert false
|
||||
| Error _ -> ()
|
||||
|
||||
let _ =
|
||||
Arg.parse
|
||||
[ ("-verbose", Arg.Unit (fun _ -> verbose := true), "Run in verbose mode") ]
|
||||
(fun x -> Printf.fprintf stderr "Ignoring argument: %s" x)
|
||||
"Test argv parser";
|
||||
|
||||
let suite =
|
||||
"parser"
|
||||
>::: [ "test parse" >:: test_parse; "negative test" >:: negative_test ]
|
||||
in
|
||||
run_test_tt ~verbose:!verbose suite
|
||||
4
unikernel/duniverse/mirage-bootvar/unix/dune
Normal file
4
unikernel/duniverse/mirage-bootvar/unix/dune
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(library
|
||||
(name mirage_bootvar_unix)
|
||||
(public_name mirage-bootvar.unix)
|
||||
(implements mirage_bootvar_backend))
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
(*
|
||||
* Copyright (c) mirage-bootvar AUTHORS
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
*)
|
||||
|
||||
let cmd_line () =
|
||||
let complete = Array.to_list Sys.argv in
|
||||
match complete with _hd :: tl -> String.concat " " tl | [] -> ""
|
||||
6
unikernel/duniverse/mirage-bootvar/xen/dune
Normal file
6
unikernel/duniverse/mirage-bootvar/xen/dune
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(library
|
||||
(name mirage_bootvar_xen)
|
||||
(public_name mirage-bootvar.xen)
|
||||
(libraries mirage-xen)
|
||||
(implements mirage_bootvar_backend)
|
||||
(optional))
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
(*
|
||||
* Copyright (c) mirage-bootvar AUTHORS
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
*)
|
||||
external cmd_line : unit -> string = "mirage_xen_get_cmdline"
|
||||
Loading…
Add table
Add a link
Reference in a new issue