summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <f4bug@amsat.org>2018-02-08 13:47:51 -0300
committerPaolo Bonzini <pbonzini@redhat.com>2018-02-13 16:15:06 +0100
commit556f9aca7f3d716185ebb05527ac3efb9709d4a5 (patch)
tree5729d5e2b09997fc99b2de6e03ee35bceb05394e
parent8640cc11a8b619da79fe354ee54a7ebcc207088f (diff)
sdhci: add check_capab_readonly() qtest
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20180208164818.7961-4-f4bug@amsat.org>
-rw-r--r--tests/sdhci-test.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/sdhci-test.c b/tests/sdhci-test.c
index 0b4bfc403c..8272c44221 100644
--- a/tests/sdhci-test.c
+++ b/tests/sdhci-test.c
@@ -65,6 +65,15 @@ static uint64_t sdhci_readq(QSDHCI *s, uint32_t reg)
return val;
}
+static void sdhci_writeq(QSDHCI *s, uint32_t reg, uint64_t val)
+{
+ if (s->pci.dev) {
+ qpci_io_writeq(s->pci.dev, s->mem_bar, reg, val);
+ } else {
+ qtest_writeq(global_qtest, s->addr + reg, val);
+ }
+}
+
static void check_capab_capareg(QSDHCI *s, uint64_t expec_capab)
{
uint64_t capab;
@@ -73,6 +82,20 @@ static void check_capab_capareg(QSDHCI *s, uint64_t expec_capab)
g_assert_cmphex(capab, ==, expec_capab);
}
+static void check_capab_readonly(QSDHCI *s)
+{
+ const uint64_t vrand = 0x123456789abcdef;
+ uint64_t capab0, capab1;
+
+ capab0 = sdhci_readq(s, SDHC_CAPAB);
+ g_assert_cmpuint(capab0, !=, vrand);
+
+ sdhci_writeq(s, SDHC_CAPAB, vrand);
+ capab1 = sdhci_readq(s, SDHC_CAPAB);
+ g_assert_cmpuint(capab1, !=, vrand);
+ g_assert_cmpuint(capab1, ==, capab0);
+}
+
static QSDHCI *machine_start(const struct sdhci_t *test)
{
QSDHCI *s = g_new0(QSDHCI, 1);
@@ -119,6 +142,7 @@ static void test_machine(const void *data)
s = machine_start(test);
check_capab_capareg(s, test->sdhci.capab.reg);
+ check_capab_readonly(s);
machine_stop(s);
}