Commit Graph

42 Commits

Author SHA1 Message Date
Richard W.M. Jones
e2c7bddf10 Update copyright dates for 2023
Run this command across the source:

  perl -pi.bak -e 's/(20[012][0-9])-20[12][012]/$1-2023/g' `git ls-files`

and remove changes to po{,-docs}/*.po{,t} (these will be regenerated
later when we run 'make dist').
2023-02-07 10:50:48 +00:00
Richard W.M. Jones
0e17236d7d Update copyright dates to 2020. 2020-03-06 19:32:32 +00:00
Pino Toscano
5d94be2583 generator: improve pod2text invocation
- feed the content directly to stdin, avoid the need of read (and write)
  a temporary file
- read all the output at once, without a tail-recursive function
- apply trimming and first line discarding after closing the process
2019-08-13 16:01:25 +02:00
Pino Toscano
81a01f20c3 generator: adjust variable names
Rename some pod2text-related variables to better-fitting names.

This is just a small refactoring.
2019-08-13 13:45:13 +02:00
Pino Toscano
da0137e828 generator: isolate memoized cache in own module
Isolate the logic for the memoized disk cache in a small module, so it
can be reused for other tools.

Other than refactoring, there should be no behaviour changes.
2019-08-13 13:19:17 +02:00
Richard W.M. Jones
05d4fcb64d Update copyright dates for 2019.
This command run over the source:

perl -pi.bak -e 's/(20[01][0-9])-2018/$1-2019/g' `git ls-files`
2019-01-08 11:58:30 +00:00
Richard W.M. Jones
212762c593 Update copyright dates for 2018.
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2017/$1-2018/g' `git ls-files`
2018-01-04 15:30:10 +00:00
Richard W.M. Jones
2d1e2d12af common/mlstdutils: Add with_open_in and with_open_out functions.
These safe wrappers around Pervasives.open_in and Pervasives.open_out
ensure that exceptions escaping cannot leave unclosed files.
2017-11-16 12:32:58 +00:00
Richard W.M. Jones
61d4891ef4 mllib: Split ‘Common_utils’ into ‘Std_utils’ + ‘Common_utils’.
The new module ‘Std_utils’ contains only functions which are pure
OCaml and depend only on the OCaml stdlib.  Therefore these functions
may be used by the generator.

The new module is moved to ‘common/mlstdutils’.

This also removes the "<stdlib>" hack, and the code which copied the
library around.

Also ‘Guestfs_config’, ‘Libdir’ and ‘StringMap’ modules are moved
since these are essentially the same.

The bulk of this change is just updating files which use
‘open Common_utils’ to add ‘open Std_utils’ where necessary.
2017-07-10 17:01:59 +01:00
Richard W.M. Jones
30411ef623 generator: Simplify the handling of string parameters.
Previously we had lots of types like String, Device, StringList,
DeviceList, etc. where Device was just a String with magical
properties (but only inside the daemon), and DeviceList was just a
list of Device strings.

Replace these with some simple top-level types:

  String
  StringList

and move the magic into a subtype.

The change is mechanical, for example:

    old                     --->    new
  FileIn "filename"               String (FileIn, "filename")
  DeviceList "devices"            StringList (Device, "devices")

Handling BufferIn is sufficiently different from a plain String
throughout all the bindings that it still uses a top-level type.
(Compare with FileIn/FileOut where the only difference is in the
protocol, but the bindings can uniformly treat it as a plain String.)

There is no semantic change, and the generated files are identical
except for a minor change in the (deprecated) Perl
%guestfs_introspection table.
2017-05-03 19:26:18 +01:00
Richard W.M. Jones
5b0fa9ced9 generator: Generate stable UUID from contents of all action*.ml files.
Also rename the function 'uuidgen ()' (conflicts with a same-named
function in Common_utils) to 'stable_uuid'.  Notice that the UUID is
now only computed once per run of the generator, whereas previously
the same value was computed over and over again.
2017-02-21 17:23:21 +00:00
Richard W.M. Jones
152657178d generator: Move failwithf to mllib.
A useful function.  This is just code motion.
2017-02-04 15:13:29 +00:00
Pino Toscano
55bf7de97c Update copyright dates for 2017
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2016/$1-2017/g' `git ls-files`

(Thanks Rich for the perl snippet, as used in past years.)
2017-01-03 16:48:21 +01:00
Richard W.M. Jones
2cc348448a generator: Share Common_utils code.
For a very long time we have maintained two sets of utility functions,
in mllib/common_utils.ml and generator/utils.ml.  This changes things
so that the same set of utility functions can be shared with both
directories.

It's not possible to use common_utils.ml directly in the generator
because it provides several functions that use modules outside the
OCaml stdlib.  Therefore we add some lightweight post-processing which
extracts the functions using only the stdlib:

  (*<stdlib>*)
  ...
  (*</stdlib>*)

and creates generator/common_utils.ml and generator/common_utils.mli
from that.  The effect is we only need to write utility functions
once.

As with other tools, we still have generator-specific utility
functions in generator/utils.ml.

Also in this change:

 - Use String.uppercase_ascii and String.lowercase_ascii in place
   of deprecated String.uppercase/String.lowercase.

 - Implement String.capitalize_ascii to replace deprecated
   String.capitalize.

 - Move isspace, isdigit, isxdigit functions to Char module.
2016-12-09 09:31:25 +00:00
Richard W.M. Jones
71a95becbd generator: Add |> (revapply) operator for compat with OCaml < 4.01. 2016-09-02 23:14:08 +01:00
Richard W.M. Jones
0c396650b0 Generate the lists of UEFI firmware paths.
Previously we had a list of UEFI paths in src/uefi.c, which was
accessed in virt-v2v using a private (guestfs_int_*) API and some C
binding code.  This was clumsy and required the paths to be replicated
in the virt-v2v unit tests.

Instead just generate the list of paths from the generator, creating
src/uefi.c and v2v/uefi.ml with the same content.

Remove the C bindings and the virt-v2v unit tests associated with UEFI
paths.
2016-08-18 14:48:51 +01:00
Richard W.M. Jones
6e79a3c84d Convert source so it can be compiled with OCaml '-safe-string' option.
OCaml 4.02 introduced the 'bytes' type, a mutable string intended to
replace the existing 'string' type for those cases where the byte
array can be mutated.  In future the 'string' type will become
immutable.  This is not the default now, but it can be forced using
the '-safe-string' compile option.

This commit changes the code so that it could be compiled using
'-safe-string' (but does not actually make that change).

If we detect OCaml < 4.02, we create a dummy 'Bytes' compatibility
module ((nearly) an alias for the 'String' module).  The only
significant difference from upstream OCaml is that you must write the
'bytes' type as 'Bytes.t' in interfaces, apart from that everything
else should work.
2016-06-16 15:22:04 +01:00
Richard W.M. Jones
bbb83aeccc generator: Remove unnecessary 'chars' function.
String.make can be used instead, and that function has been around
since at least RHEL 6 era OCaml.
2016-06-14 17:00:26 +01:00
Pino Toscano
ceefa701c6 generator: add TestRunOrUnsupported test type
Create a new TestRunOrUnsupported test type, which represents a test
sequence where a failure with ENOTSUP in the last command only marks the
test as skipped.  To be used mainly when testing features available only
with some versions of helper tools used in the appliance, for example.
2016-01-27 14:17:22 +01:00
Richard W.M. Jones
307c83177c Update copyright dates for 2016.
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2015/$1-2016/g' `git ls-files`
2016-01-02 21:19:51 +00:00
Pino Toscano
7c10cda266 generator: add a FilenameList parameter type
Mostly like StringList (so it can used in current StringList
parameters), but checking client- and daemon-side that the elements are
file names.
2015-10-21 13:00:18 +02:00
Pino Toscano
04f1f1b741 generator: small optimization of pod2text cache memoization
Instead of save every time there's a new element in the cache, batch the
saving to disk every 100 changes, saving the unsaved remainder at the
exit.

While not a big optimization, this reduces a bit the disk usage during
generator run.
2015-03-12 18:08:25 +01:00
Pino Toscano
8b268bd897 generator: add a simple HTML escaping function 2015-02-11 15:02:56 +01:00
Richard W.M. Jones
c5800dc97d Update copyright dates for 2015. 2015-01-17 09:08:15 +00:00
Pino Toscano
b10dd601fb generator: add a GUID parameter type
At the moment it is basically the change as String, and it is mapped as
if it was such.
2014-02-06 17:43:04 +01:00
Richard W.M. Jones
6c971faecf Update copyright dates for 2014. 2014-01-02 16:53:34 +00:00
Richard W.M. Jones
883aea9b1d tests: Replace TestOutputHashtable with TestResult and C test. 2013-04-13 07:26:02 +01:00
Richard W.M. Jones
c43f762257 tests: Replace TestOutputBuffer with TestResult and C test. 2013-04-13 07:26:02 +01:00
Richard W.M. Jones
424fe36d32 tests: Replace TestOutputFileMD5 with TestResult and C test. 2013-04-13 07:26:02 +01:00
Richard W.M. Jones
0a49838135 tests: Remove TestOutputLength (not used by any tests). 2013-04-13 07:26:02 +01:00
Richard W.M. Jones
685c5fb3b1 tests: Replace TestOutput/TestOutputDevice with TestResult{String,Device}. 2013-04-13 07:26:02 +01:00
Richard W.M. Jones
45840581d6 tests: Replace TestOutputList{,OfDevices} with TestResult.
This adds helper C functions 'is_string_list' and 'is_device_list'
allowing these tests to be carried out in generic C code instead of as
specialized tests.
2013-04-13 07:25:57 +01:00
Richard W.M. Jones
45599a8895 tests: Replace TestOutputStruct with TestResult. 2013-04-12 21:26:23 +01:00
Richard W.M. Jones
24fdf05d30 tests: Replace TestOutputInt{,Op} with TestResult. 2013-04-12 21:26:23 +01:00
Richard W.M. Jones
c9ef854f83 tests: Replace TestOutputTrue/False with TestResultTrue/False. 2013-04-12 21:26:23 +01:00
Richard W.M. Jones
008be5dbfa tests: More flexible re-implementation of C API tests.
Instead of using the various 'TestOutput', 'TestOutputList' etc
macros, it makes better sense to let the tests contain fragments of C
code to perform the checks.

Several new macros are added:

- 'TestResult': This macro takes a C expression which is evaluated to
test the result of commands.  For example to compare if a string
result has some value:

   TestResult (* command sequence *), "STREQ (ret, \"abcd\")"

The variable "ret" contains the result from the last command in the
sequence.  But also, variables "ret1", "ret2", etc contain the results
from the last but one command, the command before that, and so forth,
allowing much more flexible tests to be written.

- 'TestResultTrue', 'TestResultFalse': Wrappers that test the last
command for true/false.
2013-04-12 21:26:23 +01:00
Richard W.M. Jones
a3de6eddd4 pod: Fix "wide character in print" warnings by declaring encoding correctly. 2013-04-05 10:33:25 +01:00
Matthew Booth
ef2276654e generator: Create Mountable_or_Path, initially identical to Dev_or_Path 2013-02-11 15:43:53 +00:00
Matthew Booth
8fb2306be4 generator: Add new Mountable argument type
This type is initially identical to Device.
2013-02-08 14:59:00 +00:00
Richard W.M. Jones
0d18a8b407 Update copyright dates for 2013. 2013-02-02 13:56:19 +00:00
Richard W.M. Jones
2cac8d490e syntax: Remove trailing whitespace.
Found by 'make syntax-check'.
2012-09-15 13:36:02 +01:00
Richard W.M. Jones
d331fd70e2 generator: Rename 'generator_*' as '*'.
This is a simple renaming of the files/modules.

Note that in OCaml, module names are derived from filenames by
capitalizing the first letter.  Thus the old module names had the form
"Generator_api_versions".  The new modules names have the form
"Api_versions".
2012-09-02 19:47:33 +01:00