Nico Huber has submitted this change. ( https://review.coreboot.org/c/flashrom/+/57914 )
Change subject: tests: Move LOG_ME to include/tests.h to be available everywhere
......................................................................
tests: Move LOG_ME to include/tests.h to be available everywhere
LOG_ME macro is very generic and can be useful anywhere in tests.
Previously was only used in scope of tests.c. With time more tests
are added, and more files, LOG_ME needs to be visible everywhere.
BUG=b:181803212
TEST=builds and ninja test
Change-Id: If7f3d256161bc8b81e996328e445cccab9a82174
Signed-off-by: Anastasia Klimchuk <aklm(a)chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/57914
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org>
Reviewed-by: Nico Huber <nico.h(a)gmx.de>
---
M tests/include/test.h
M tests/tests.c
2 files changed, 2 insertions(+), 3 deletions(-)
Approvals:
build bot (Jenkins): Verified
Nico Huber: Looks good to me, approved
diff --git a/tests/include/test.h b/tests/include/test.h
index ee7b4cf..bf8c4f7 100644
--- a/tests/include/test.h
+++ b/tests/include/test.h
@@ -35,4 +35,6 @@
*/
void *not_null(void);
+#define LOG_ME printf("%s is called\n", __func__)
+
#endif /* _TESTS_TEST_H */
diff --git a/tests/tests.c b/tests/tests.c
index 9dadddf..329e798 100644
--- a/tests/tests.c
+++ b/tests/tests.c
@@ -21,9 +21,6 @@
#include <string.h>
#include <stdint.h>
-/* redefinitions/wrapping */
-#define LOG_ME printf("%s is called\n", __func__)
-
void *not_null(void)
{
return (void *)NON_ZERO;
4 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
--
To view, visit https://review.coreboot.org/c/flashrom/+/57914
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: If7f3d256161bc8b81e996328e445cccab9a82174
Gerrit-Change-Number: 57914
Gerrit-PatchSet: 6
Gerrit-Owner: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-MessageType: merged
Nico Huber has submitted this change. ( https://review.coreboot.org/c/flashrom/+/57269 )
Change subject: tests: Add NON_ZERO macro and not_null function instead of MOCK_HANDLE
......................................................................
tests: Add NON_ZERO macro and not_null function instead of MOCK_HANDLE
This patch adds NON_ZERO macro and not_null function into io_mock.h,
so that they can be used anywhere in tests. Common usage for not_null
is to indicate a valid pointer, where it doesn't matter what the
pointer is, only matters it is not null. Common usage of NON_ZERO is
to indicate a valid file descriptor, where it only matters the
descriptor is non-zero integer.
New features replace all usages of previous MOCK_HANDLE.
This patch corrects return value from __wrap_ioctl to be successful
by default. It used to be MOCK_HANDLE, but should be 0. Included in
this patch because this is also a replacement of MOCK_HANDLE.
BUG=b:181803212
TEST=builds and ninja test
Change-Id: I5ad6ee4aa9091447c6c9108c92bf7f6e755fca48
Signed-off-by: Anastasia Klimchuk <aklm(a)chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/57269
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org>
Reviewed-by: Nico Huber <nico.h(a)gmx.de>
---
M tests/include/test.h
M tests/init_shutdown.c
M tests/tests.c
3 files changed, 23 insertions(+), 13 deletions(-)
Approvals:
build bot (Jenkins): Verified
Nico Huber: Looks good to me, approved
diff --git a/tests/include/test.h b/tests/include/test.h
index 24fa963..ee7b4cf 100644
--- a/tests/include/test.h
+++ b/tests/include/test.h
@@ -27,4 +27,12 @@
#include <setjmp.h>
#include <cmocka.h>
+#define NON_ZERO (0xf000baaa)
+
+/*
+ * Having this as function allows to set a breakpoint on the address,
+ * as it has a named symbol associated with the address number.
+ */
+void *not_null(void);
+
#endif /* _TESTS_TEST_H */
diff --git a/tests/init_shutdown.c b/tests/init_shutdown.c
index 90bde1e..03e888f 100644
--- a/tests/init_shutdown.c
+++ b/tests/init_shutdown.c
@@ -19,8 +19,6 @@
#include "io_mock.h"
#include "programmer.h"
-#define NOT_NULL ((void *)0xf000baaa)
-
static void run_lifecycle(void **state, const struct programmer_entry *prog, const char *param)
{
(void) state; /* unused */
@@ -100,7 +98,7 @@
io_state->fopen_path = strdup(pathname);
- return NOT_NULL;
+ return not_null();
}
size_t linux_mtd_fread(void *state, void *buf, size_t size, size_t len, FILE *fp)
diff --git a/tests/tests.c b/tests/tests.c
index ac59470..9dadddf 100644
--- a/tests/tests.c
+++ b/tests/tests.c
@@ -23,7 +23,11 @@
/* redefinitions/wrapping */
#define LOG_ME printf("%s is called\n", __func__)
-#define MOCK_HANDLE 2021
+
+void *not_null(void)
+{
+ return (void *)NON_ZERO;
+}
static const struct io_mock *current_io = NULL;
@@ -54,7 +58,7 @@
}
struct pci_dev mock_pci_dev = {
- .device_id = MOCK_HANDLE,
+ .device_id = NON_ZERO,
};
struct pci_dev *__wrap_pcidev_init(void *devs, int bar)
@@ -66,7 +70,7 @@
uintptr_t __wrap_pcidev_readbar(void *dev, int bar)
{
LOG_ME;
- return MOCK_HANDLE;
+ return NON_ZERO;
}
void __wrap_sio_write(uint16_t port, uint8_t reg, uint8_t data)
@@ -85,7 +89,7 @@
LOG_ME;
if (current_io && current_io->open)
return current_io->open(current_io->state, pathname, flags);
- return MOCK_HANDLE;
+ return NON_ZERO;
}
int __wrap_open64(const char *pathname, int flags)
@@ -93,7 +97,7 @@
LOG_ME;
if (current_io && current_io->open)
return current_io->open(current_io->state, pathname, flags);
- return MOCK_HANDLE;
+ return NON_ZERO;
}
int __wrap_ioctl(int fd, unsigned long int request, ...)
@@ -107,7 +111,7 @@
va_end(args);
return out;
}
- return MOCK_HANDLE;
+ return 0;
}
int __wrap_write(int fd, const void *buf, size_t sz)
@@ -131,7 +135,7 @@
LOG_ME;
if (current_io && current_io->fopen)
return current_io->fopen(current_io->state, pathname, mode);
- return (void *)MOCK_HANDLE;
+ return not_null();
}
FILE *__wrap_fopen64(const char *pathname, const char *mode)
@@ -139,7 +143,7 @@
LOG_ME;
if (current_io && current_io->fopen)
return current_io->fopen(current_io->state, pathname, mode);
- return (void *)MOCK_HANDLE;
+ return not_null();
}
int __wrap_stat(const char *path, void *buf)
@@ -197,7 +201,7 @@
int __wrap_fileno(FILE *fp)
{
LOG_ME;
- return MOCK_HANDLE;
+ return NON_ZERO;
}
int __wrap_fsync(int fd)
@@ -292,7 +296,7 @@
libusb_context *usb_ctx, uint16_t vid, uint16_t pid, unsigned int num)
{
LOG_ME;
- return (void *)MOCK_HANDLE;
+ return not_null();
}
int __wrap_libusb_set_configuration(libusb_device_handle *devh, int config)
6 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
--
To view, visit https://review.coreboot.org/c/flashrom/+/57269
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I5ad6ee4aa9091447c6c9108c92bf7f6e755fca48
Gerrit-Change-Number: 57269
Gerrit-PatchSet: 8
Gerrit-Owner: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-MessageType: merged
Attention is currently required from: Angel Pons, Anastasia Klimchuk.
Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/58103 )
Change subject: tests: Add wraps for all variants of stat
......................................................................
Patch Set 2:
(1 comment)
Commit Message:
https://review.coreboot.org/c/flashrom/+/58103/comment/683a4b09_b4c4a0d6
PS2, Line 9: all
When considering non-standard symbol names, there is no "all". People
could name it whatever they want.
Please mention what environment this exactly applies to. If we don't
keep track of such things, we'd have to carry the baggage forever
(we could never be sure what breaks if some quirk handling would be
removed).
--
To view, visit https://review.coreboot.org/c/flashrom/+/58103
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I4c5c243acde09dc5bb6b2a14042fcd23a49707db
Gerrit-Change-Number: 58103
Gerrit-PatchSet: 2
Gerrit-Owner: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Comment-Date: Mon, 18 Oct 2021 09:49:02 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: Nico Huber, Angel Pons, Anastasia Klimchuk.
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/58103 )
Change subject: tests: Add wraps for all variants of stat
......................................................................
Patch Set 2:
(1 comment)
Commit Message:
https://review.coreboot.org/c/flashrom/+/58103/comment/d1bfaa58_5e6aefe6
PS2, Line 17: TEST=running tests on two different environments,
: with 1) stat64 and 2) __xstat64 invoked
this does sound like minijail sort of thing although the change is harmless. I would investigate if this was a policy change in the test environment before being sure we need this wrap?
--
To view, visit https://review.coreboot.org/c/flashrom/+/58103
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I4c5c243acde09dc5bb6b2a14042fcd23a49707db
Gerrit-Change-Number: 58103
Gerrit-PatchSet: 2
Gerrit-Owner: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Comment-Date: Mon, 18 Oct 2021 03:58:58 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: Nico Huber, Thomas Heijligen, Edward O'Callaghan, Angel Pons.
Anastasia Klimchuk has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/57918 )
Change subject: tests: Add init-shutdown test for raiden_debug_spi
......................................................................
Patch Set 5:
(2 comments)
This change is ready for review.
File tests/init_shutdown.c:
https://review.coreboot.org/c/flashrom/+/57918/comment/78f4786d_74f2cf50
PS5, Line 122: (void *)
I added cast to avoid warnings about discarding const qualifier, hope it's ok.
File tests/io_mock.h:
https://review.coreboot.org/c/flashrom/+/57918/comment/16a3c10b_09495b96
PS4, Line 42: struct libusb_endpoint_descriptor {
: uint8_t offset1[2];
: uint8_t bEndpointAddress;
: uint8_t bmAttributes;
: uint8_t offset2[5];
: unsigned char *extra;
: int extra_length;
: };
: typedef struct libusb_endpoint_descriptor libusb_endpoint_descriptor;
:
: struct libusb_interface_descriptor {
: uint8_t offset1[2];
: uint8_t bInterfaceNumber;
: uint8_t bAlternateSetting;
: uint8_t bNumEndpoints;
: uint8_t bInterfaceClass;
: uint8_t bInterfaceSubClass;
: uint8_t bInterfaceProtocol;
: uint8_t offset2;
: struct libusb_endpoint_descriptor *endpoint;
: };
: typedef struct libusb_interface_descriptor libusb_interface_descriptor;
:
: struct libusb_interface {
: struct libusb_interface_descriptor *altsetting;
: int num_altsetting;
: };
: typedef struct libusb_interface libusb_interface;
:
: struct libusb_config_descriptor {
: uint8_t offset1[4];
: uint8_t bNumInterfaces;
: uint8_t bConfigurationValue;
: uint8_t offset2[3];
: struct libusb_interface *interface;
: };
: typedef struct libusb_config_descriptor libusb_config_descriptor;
:
: struct libusb_device {};
: typedef struct libusb_device libusb_device;
:
: struct libusb_device_descriptor {
: uint8_t offset1[8];
: uint16_t idVendor;
: uint16_t idProduct;
: uint8_t offset2[5];
: uint8_t bNumConfigurations;
: };
: typedef struct libusb_device_descriptor libusb_device_descriptor;
> > I will re-work this patch, so that tests just include libusb.h always. […]
I included the header only once in io_mock.h and it seems to work!
One thing I am not sure about, you said to "require libusb to be around to build the tests", does it mean require it in meson build? I haven't done this last bit yet, need to see what is the right way to express the requirement.
As an experiment, I changed the line into
#include <libusb666.h>
and the error is:
../tests/io_mock.h:41:10: fatal error: libusb666.h: No such file or directory
maybe it's not a user-friendly error...
--
To view, visit https://review.coreboot.org/c/flashrom/+/57918
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I880a8637ab02de179df9169c1898230bce4dc1c7
Gerrit-Change-Number: 57918
Gerrit-PatchSet: 5
Gerrit-Owner: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-Attention: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: Thomas Heijligen <src(a)posteo.de>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Comment-Date: Mon, 18 Oct 2021 02:55:54 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Nico Huber <nico.h(a)gmx.de>
Comment-In-Reply-To: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-MessageType: comment
Attention is currently required from: Nico Huber, David Hendricks, Edward O'Callaghan, Daniel Campello, Angel Pons.
Anastasia Klimchuk has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/52362 )
Change subject: cli_classic.c: Make -r/-w/-v argument optional
......................................................................
Patch Set 18:
(1 comment)
File cli_classic.c:
https://review.coreboot.org/c/flashrom/+/52362/comment/9ec47735_85bb460b
PS18, Line 733: for (arg = include_args; arg; arg = arg->next) {
: if (check_filename(arg->file, "region")) {
: ret = 1;
: goto out_shutdown;
: }
: }
Not sure what is the status of this patch, but seems like it needs to be updated because I have just modified this chunk of code in chromium tree: https://chromium-review.googlesource.com/c/chromiumos/third_party/flashrom/… (hope the link is visible to everyone? if not tell me please).
I read the latest few comments, and it not entirely clear to me what is the plan for this patch: complete or abandon?
--
To view, visit https://review.coreboot.org/c/flashrom/+/52362
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I15384b92cb987a6ea1bb4369ef415488b9cf7f41
Gerrit-Change-Number: 52362
Gerrit-PatchSet: 18
Gerrit-Owner: Daniel Campello <campello(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-CC: Nikolai Artemiev <nartemiev(a)google.com>
Gerrit-CC: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-Attention: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Daniel Campello <campello(a)chromium.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Comment-Date: Sun, 17 Oct 2021 22:54:00 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment