Hi, On 11/2/21 11:59, Richard Henderson wrote: > From: Shengtan Mao <st...@google.com> > > Signed-off-by: Shengtan Mao <st...@google.com> > Signed-off-by: Hao Wu <wuhao...@google.com> > Reviewed-by: Hao Wu <wuhao...@google.com> > Reviewed-by: Chris Rauer <cra...@google.com> > Reviewed-by: Tyrone Ting <kft...@nuvoton.com> > Reviewed-by: Peter Maydell <peter.mayd...@linaro.org> > Message-Id: <20211008002628.1958285-6-wuhao...@google.com> > Signed-off-by: Richard Henderson <richard.hender...@linaro.org> > --- > tests/qtest/npcm7xx_sdhci-test.c | 209 +++++++++++++++++++++++++++++++ > tests/qtest/meson.build | 1 + > 2 files changed, 210 insertions(+) > create mode 100644 tests/qtest/npcm7xx_sdhci-test.c
> +static void write_sdread(QTestState *qts, const char *msg) > +{ > + size_t len = strlen(msg); > + char *rmsg = g_malloc(len); > + > + /* write message to sd */ > + int fd = open(sd_path, O_WRONLY); > + int ret; > + > + g_assert(fd > 0); > + ret = write(fd, msg, len); > + g_assert(ret == len); > + ret = close(fd); > + g_assert(ret == 0); > + > + /* read message using sdhci */ > + ret = sdhci_read_cmd(qts, NPCM7XX_MMC_BA, rmsg, len); > + g_assert(ret == len); > + g_assert(!strcmp(rmsg, msg)); > + > + free(rmsg); > +} > +static void sdwrite_read(QTestState *qts, const char *msg) > +{ > + size_t len = strlen(msg); > + char *rmsg = g_malloc(len); > + > + /* write message using sdhci */ > + sdhci_write_cmd(qts, NPCM7XX_MMC_BA, msg, len, NPCM7XX_BLK_SIZE); > + > + /* read message from sd */ > + int fd = open(sd_path, O_RDONLY); > + int ret; > + > + g_assert(fd > 0); > + ret = read(fd, rmsg, len); > + g_assert(ret == len); > + ret = close(fd); > + g_assert(ret == 0); > + > + g_assert(!strcmp(rmsg, msg)); Looking at this failure on s390x host (big-endian) with Richard: https://app.travis-ci.com/gitlab/qemu-project/qemu/jobs/546307442#L9370 ERROR:../tests/qtest/npcm7xx_sdhci-test.c:104:sdwrite_read: assertion failed: (!strcmp(rmsg, msg)) ERROR qtest-arm/npcm7xx_sdhci-test - Bail out! ERROR:../tests/qtest/npcm7xx_sdhci-test.c:104:sdwrite_read: assertion failed: (!strcmp(rmsg, msg)) it seems you want to use strncmp() or memcmp() here. > + free(rmsg); > +}