Commit Graph

53 Commits

Author SHA1 Message Date
Richard W.M. Jones
e6c89f9631 utils: Rename ‘guestfs-internal-frontend.h’ to ‘guestfs-utils.h’.
The reason it's not just ‘utils.h’ is because Pino is worried that we
might pick up /usr/include/utils.h from a rogue library.
2017-07-10 17:01:59 +01:00
Richard W.M. Jones
5efebd8c7e utils: Split out structs cleanups and printing into common/structs.
These won't be used by the daemon, so interferes with us using
common/utils in the daemon, so they are moved to a different library.
2017-07-10 17:01:59 +01: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
994a8f6a71 generator: Add a function to find an action by name.
Fairly simple refactoring.
2017-03-03 16:56:52 +00:00
Richard W.M. Jones
18777adf31 generator: Stablise output of common/protocol/*, daemon/*, lib/* and tests/c-api/tests.c
Sort the functions so the output is stable.

This changes the order in which the C API tests run.  Previously we
ran the newest tests first, which was useful when we were frequently
adding new APIs.  Now we run them in sorted order.
2017-02-21 17:23:21 +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
c540676f5e Remove most instances of OCaml warning 52.
See:
http://caml.inria.fr/pub/docs/manual-ocaml/comp.html#s:comp-warnings
2016-12-09 09:31:25 +00: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
f8978239e3 generator: Move all actions into a single list and add filter functions.
This mostly mechanical change moves all of the libguestfs API
lists of functions into a struct in the Actions module.

It also adds filter functions to be used elsewhere to get
subsets of these functions.

Original code         Replacement

all_functions         actions

daemon_functions      actions |> daemon_functions
non_daemon_functions  actions |> non_daemon_functions
external_functions    actions |> external_functions
internal_functions    actions |> internal_functions
documented_functions  actions |> documented_functions
fish_functions        actions |> fish_functions

*_functions_sorted    ... replacement as above ... |> sort
2016-09-02 23:14:08 +01:00
Richard W.M. Jones
ae3c051567 generator: Declare which input file(s) generate each output file. 2016-02-23 10:40:06 +00: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
Richard W.M. Jones
c5800dc97d Update copyright dates for 2015. 2015-01-17 09:08:15 +00:00
Pino Toscano
349536bf70 tests/c-api: add a way to skip test when host and appliance differ
Add a IfNotCrossAppliance prereq for tests, so a test using it can only
be run when the appliance is a copy of the running host system; this can
help marking tests which run stuff (usually built in the host) inside
the appliance.
2014-10-23 19:03:12 +02:00
Pino Toscano
abd93812ca tests: isolate iso_system_id baseline string
Move the reference iso_system_id for the isoinfo_device test to an own
define for Linux, with an error for unknown OSes.
2014-10-23 19:03:12 +02:00
Richard W.M. Jones
3562a81683 generator: Change type of 'tests' to 'c_api_tests'.
Just a code refactoring, has no functional effect.
2014-09-17 17:31:50 +01: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
8a3ecfc04e tests/c-api: Remove 'GETKEY:' hack since it's no longer used anywhere. 2013-07-20 16:31:42 +01:00
Richard W.M. Jones
86ca8af9f1 tests: c-api: Add a cleanup function for tests.
By specifying a cleanup function we can ensure that Augeas and hivex
functions can be tested.

There is no functional change here, verified by diffing the generated
file tests/c-api/tests.c before and after.
2013-07-06 20:46:45 +01:00
Richard W.M. Jones
b5a938f464 tests: Fix mix up of actual/expected in error messages. 2013-07-06 20:46:45 +01:00
Richard W.M. Jones
5faba45fe1 tests/c-api: Various code refactorings.
- Don't use fixed names for the disks.  This will allow us to
  parallelize this test.

- Add a new "GETKEY:<key>" String parameter which can retrieve keys
  from the handle.  The temporary disk names are stored as keys.

- Don't test the close callback.  However this uses the close callback
  mechanism to delete the temporary disks, and in any case close
  callbacks are well tested by the language binding tests.

- The generated code now produces a static array of tests (instead of
  a 'perform_tests' function), making it possible to parallelize.
2013-05-01 11:13:31 +01:00
Richard W.M. Jones
f003c50c52 tests/c-api: Remove global guestfs handle.
This will allow us to parallelize these tests.
2013-05-01 09:34:39 +01:00
Richard W.M. Jones
9d5236d73c tests/c-api: Factor out common init_* into separate functions. 2013-05-01 09:09:55 +01:00
Richard W.M. Jones
b7da435003 tests/c-api: Allow FileIn paths to be prefixed by "$srcdir".
Since tests involving FileIn will often wish to read from local files,
it makes sense that they would want to open files in $srcdir.

Therefore allow such paths to be prefixed by "$srcdir" which is
substituted at run time by the same named environment variable (set by
automake).

This fixes separated builds in tests/c-api directory.
2013-04-25 12:22:31 +01:00
Richard W.M. Jones
288a24eebe tests: Split C API tests into regular C file + generated tests file. 2013-04-13 07:26:46 +01: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
e327351304 tests: 'If' and 'Unless' conditions never used, so remove them. 2013-04-12 21:26:23 +01:00
Richard W.M. Jones
df656c9d5a tests: Make it easier to grep failures out of the log file. 2013-03-14 08:56:29 +00:00
Matthew Booth
ef2276654e generator: Create Mountable_or_Path, initially identical to Dev_or_Path 2013-02-11 15:43:53 +00:00
Richard W.M. Jones
59b296fecc tools, tests: Use "guestfs-internal-frontend.h" header.
Instead of redefining STREQ, etc.
2013-02-08 16:15:25 +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
Matthew Booth
956e30effa Add support for getting and setting GPT partition type GUIDs
New APIs:
  part_set_gpt_type
  part_get_gpt_type
2012-12-14 16:58:05 +00:00
Richard W.M. Jones
a74f168168 tests: More efficient use of strings in the object code.
No functional change.
2012-11-09 22:48:47 +00:00
Richard W.M. Jones
a270faefef tests: Use guestfs_{push,pop}_error_handler.
Replace the custom error handler with calls to
guestfs_{push,pop}_error_handler only where necessary.  This
simplifies the generated code.
2012-11-09 22:48:47 +00:00
Richard W.M. Jones
2deb235cf4 tests: Cleanup code that prints each test name.
This is just code motion.
2012-11-09 22:48:47 +00:00
Richard W.M. Jones
56c7967cad tests: Change code for printing warnings about untested functions.
Just code cleanup, no functional change.
2012-11-09 20:19:30 +00:00
Richard W.M. Jones
04a8cffee7 tests: Remove dead code in generated output. 2012-11-09 20:19:08 +00:00