Daniel Henrique Barboza
2d9b8acf58
virpcimock.c: simplify getrealpath() usage
...
Previous patch had to add '/sys/kernel/' prefix in opendir() because
the path, which is being mocked, wasn't being considered due to
an 'if SYSFS_PCI_PREFIX' guarding the call to getrealpath().
In fact, all current getrealpath() callers are guarding it with a
conditional to ensure that the function will never be called with
a non-mocked path. In this case, an extra non-NULL verification is
needed for the 'newpath' string to use the variable - which is
counterintuitive, given that getrealpath() will always write the
'newpath' string in any non-error conditon.
However, simply removing the guard of all getrealpath() instances
causes an abort in init_env(). This happens because tests will
execute access() to non-mocked paths even before the
LIBVIRT_FAKE_ROOT_DIR variable is declared in the test files. We
don't need 'fakerootdir' to be created at this point though.
This patch does the following changes to simplify getrealpath()
usage:
- getrealpath() will now guard the init_env() call by checking if
both fakeroot isn't created and the required path is being mocked.
This ensures that we're not failing inside init_env() because
we're too early and LIBVIRT_FAKE_ROOT_DIR wasn't defined yet;
- remove all conditional guards to call getrealpath() from
access(), virMockStatRedirect(), open(), open_2(), opendir()
and virFileCanonicalizePath(). As a bonus, remove all ternary
conditionals with 'newpath';
- a new 'pathPrefixIsMocked()' helper to aggregate all the prefixes
we're mocking, making it easier to add/remove them. If a prefix
is added inside this function, we can be sure that all functions
are mocking them.
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2019-09-09 16:44:24 +02:00
..
2019-02-24 13:20:51 +04:00
2019-02-24 13:20:51 +04:00
2018-12-03 14:31:41 +01:00
2019-07-29 16:27:05 +02:00
2019-06-20 14:02:36 +02:00
2019-08-23 10:48:34 +02:00
2019-08-20 15:36:36 +02:00
2019-04-16 13:46:17 +02:00
2019-03-13 12:06:52 -06:00
2019-03-06 15:53:53 +01:00
2019-07-17 17:18:56 -04:00
2019-05-23 16:29:48 +01:00
2019-07-17 17:18:56 -04:00
2019-07-17 17:18:56 -04:00
2019-03-22 12:59:56 +03:00
2019-08-09 12:17:19 +02:00
2019-09-04 09:13:49 +02:00
2019-09-06 12:47:47 +02:00
2019-02-05 17:15:05 +01:00
2019-07-26 16:48:58 -05:00
2019-07-26 16:48:58 -05:00
2019-07-08 16:10:22 -05:00
2019-07-08 16:10:22 -05:00
2019-03-12 15:29:44 +01:00
2019-08-29 16:36:26 +02:00
2019-09-09 16:44:24 +02:00
2019-09-09 16:44:24 +02:00
2019-07-18 17:59:33 +02:00
2019-08-16 13:26:10 +02:00
2019-09-09 16:44:24 +02:00
2019-09-09 16:44:24 +02:00
2019-07-26 09:59:27 +01:00
2019-07-12 17:09:43 +02:00
2019-01-29 19:16:19 -05:00
2019-06-25 17:11:56 +02:00
2019-06-25 17:11:56 +02:00
2018-12-17 14:43:33 +00:00
2018-12-17 14:43:33 +00:00
2019-03-06 11:12:48 -05:00
2019-06-03 17:59:38 +02:00
2018-09-20 13:06:02 -04:00
2018-10-05 15:53:29 +02:00
2019-06-21 12:59:42 +01:00
2019-07-19 10:52:06 +02:00
2019-04-03 14:44:32 +02:00
2019-07-12 16:55:39 +01:00
2019-07-16 13:42:39 +02:00
2019-06-17 15:19:54 +01:00
2019-09-09 16:44:24 +02:00
2019-04-15 20:03:55 -04:00
2019-04-16 13:11:08 -04:00
2019-04-16 13:11:08 -04:00
2019-04-15 20:03:55 -04:00
2019-08-27 15:49:48 +02:00
2019-08-27 15:49:48 +02:00
2019-08-27 15:49:48 +02:00
2019-08-23 11:26:26 +01:00
2019-08-07 16:54:02 +01:00
2019-08-27 15:56:17 +02:00
2019-02-11 17:40:44 -05:00
2019-08-23 11:26:26 +01:00
2018-12-13 16:08:38 +00:00
2018-09-20 10:16:39 +02:00
2019-04-10 12:26:32 +02:00
2019-08-23 11:26:26 +01:00
2018-12-13 16:08:38 +00:00
2019-04-16 13:46:17 +02:00
2019-04-11 12:47:23 -04:00
2018-09-20 10:16:39 +02:00
2019-02-11 17:40:44 -05:00
2019-08-23 11:26:26 +01:00
2018-12-11 15:03:08 -05:00
2018-09-20 10:16:39 +02:00
2019-09-09 16:44:24 +02:00
2019-03-08 14:59:20 +01:00
2019-07-17 17:18:56 -04:00
2019-07-17 17:18:56 -04:00
2019-07-17 17:18:56 -04:00
2019-07-17 17:18:56 -04:00
2018-09-20 10:16:39 +02:00
2018-12-13 16:08:38 +00:00
2018-12-13 16:08:38 +00:00
2019-08-23 11:26:26 +01:00
2018-12-14 10:47:13 +00:00
2019-03-14 10:05:25 +01:00
2018-09-20 10:16:39 +02:00
2019-04-10 12:26:32 +02:00
2018-12-17 17:52:46 +01:00
2018-09-20 10:16:39 +02:00
2019-08-29 12:03:23 +02:00
2019-09-06 08:12:21 +02:00
2019-06-07 16:18:45 +02:00
2018-12-13 16:08:38 +00:00
2019-08-23 11:26:26 +01:00
2019-08-23 11:26:26 +01:00
2018-12-13 16:08:38 +00:00
2019-06-03 18:07:16 +02:00
2019-08-09 13:55:54 +02:00
2019-08-09 13:55:54 +02:00
2019-04-10 13:58:30 +02:00
2019-09-09 16:44:24 +02:00
2019-08-23 11:26:26 +01:00
2018-12-14 10:47:13 +00:00
2019-08-27 15:56:17 +02:00
2019-06-20 13:47:41 +02:00
2019-06-19 17:12:34 +02:00
2019-08-22 17:05:17 +02:00
2019-07-03 08:36:04 +02:00
2019-07-03 08:36:04 +02:00
2019-01-24 18:59:38 -05:00
2019-09-06 12:47:47 +02:00
2019-08-28 12:26:43 +02:00
2019-04-10 12:26:32 +02:00
2018-11-16 13:42:39 +01:00
2019-07-26 09:59:27 +01:00
2018-09-20 10:16:39 +02:00
2019-08-27 15:56:17 +02:00
2018-11-16 13:42:39 +01:00
2018-09-20 10:16:39 +02:00
2018-09-20 10:16:39 +02:00
2019-08-23 11:26:26 +01:00
2018-12-13 16:08:38 +00:00
2019-02-12 08:51:23 -05:00
2019-03-07 12:12:11 +01:00
2019-08-27 15:49:48 +02:00
2019-06-25 17:11:56 +02:00
2019-02-12 08:51:23 -05:00
2019-02-12 08:51:23 -05:00
2019-06-03 17:51:12 +02:00
2019-04-04 09:35:40 -05:00
2019-08-27 15:49:48 +02:00
2019-08-27 15:56:17 +02:00
2019-06-19 17:12:34 +02:00
2018-09-20 10:16:39 +02:00
2019-06-19 17:12:34 +02:00
2019-08-27 15:56:17 +02:00
2019-09-06 12:47:47 +02:00
2019-08-27 15:56:17 +02:00
2019-06-19 17:12:34 +02:00
2018-11-26 16:38:26 -07:00
2019-06-19 17:12:34 +02:00
2019-08-27 15:49:48 +02:00
2019-04-10 12:26:32 +02:00
2018-12-13 16:08:38 +00:00
2019-06-04 09:29:35 +02:00
2019-08-27 15:49:48 +02:00
2019-08-23 11:26:26 +01:00
2018-09-20 10:16:39 +02:00
2019-04-10 09:12:04 +02:00
2019-08-23 11:26:26 +01:00
2018-09-20 10:16:39 +02:00
2019-08-23 11:26:26 +01:00
2018-12-13 16:08:38 +00:00
2018-12-14 10:47:13 +00:00
2018-12-13 16:08:38 +00:00
2018-12-17 17:52:46 +01:00
2019-08-27 15:56:17 +02:00
2019-08-23 11:26:26 +01:00
2019-07-19 10:52:06 +02:00
2019-08-23 11:26:26 +01:00
2019-08-23 11:26:26 +01:00
2019-06-19 17:12:34 +02:00
2019-09-06 12:47:46 +02:00
2019-06-19 17:12:34 +02:00
2019-08-27 15:58:51 +02:00
2019-08-27 15:49:48 +02:00
2019-08-27 16:10:21 +02:00
2018-12-13 16:08:38 +00:00
2019-08-23 11:26:26 +01:00
2019-08-27 15:56:17 +02:00
2019-04-11 12:47:23 -04:00
2018-12-13 16:08:38 +00:00
2019-02-14 18:03:10 +01:00
2019-04-10 12:26:32 +02:00
2019-08-27 15:49:48 +02:00
2019-08-23 11:26:26 +01:00
2019-08-23 11:26:26 +01:00
2019-08-23 11:26:26 +01:00
2018-12-13 16:08:38 +00:00
2019-08-27 15:49:48 +02:00
2019-07-09 15:01:54 +02:00
2019-08-23 11:26:26 +01:00
2018-12-13 16:08:38 +00:00
2019-07-16 13:42:39 +02:00
2019-08-23 11:26:26 +01:00
2018-12-13 16:08:38 +00:00
2018-12-13 16:08:38 +00:00
2019-08-23 11:26:26 +01:00
2019-07-11 15:26:54 +01:00
2019-08-23 11:26:26 +01:00
2019-04-10 12:26:32 +02:00
2019-06-19 17:12:34 +02:00
2019-08-23 11:26:26 +01:00
2019-06-17 15:19:54 +01:00
2018-09-20 10:16:39 +02:00
2019-09-09 16:44:24 +02:00
2019-08-27 15:49:48 +02:00
2019-09-06 12:47:46 +02:00
2018-12-13 16:08:38 +00:00
2019-08-23 11:26:26 +01:00
2019-09-09 16:44:24 +02:00
2018-12-13 16:08:38 +00:00
2019-08-27 15:49:48 +02:00
2018-12-13 16:08:38 +00:00
2019-08-19 11:52:44 +01:00
2019-04-10 12:26:32 +02:00
2019-08-02 09:44:41 -05:00
2019-07-29 15:56:46 +02:00
2019-08-02 09:44:41 -05:00
2018-10-12 09:30:56 -05:00
2019-04-04 09:35:40 -05:00
2019-03-25 09:01:53 -05:00
2019-08-26 13:49:17 +02:00
2019-02-12 08:51:23 -05:00
2018-12-13 16:08:38 +00:00
2019-08-23 11:26:26 +01:00
2019-01-23 07:54:58 +01:00
2019-05-07 11:01:14 +02:00
2018-12-13 16:08:38 +00:00
2018-09-20 10:16:38 +02:00
2019-08-26 13:49:16 +02:00
2018-12-13 16:08:38 +00:00
2019-08-23 11:26:26 +01:00
2018-09-20 10:16:39 +02:00
2019-04-15 20:03:55 -04:00
2019-02-12 10:14:53 +01:00
2019-08-26 11:06:12 -06:00
2019-08-26 11:06:12 -06:00
2019-04-15 20:03:55 -04:00