[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 17/17] tests/qtest/tmp105-test: Trivial test for TempSensorCl
From: |
Philippe Mathieu-Daudé |
Subject: |
[RFC PATCH 17/17] tests/qtest/tmp105-test: Trivial test for TempSensorClass |
Date: |
Tue, 21 Apr 2020 14:16:26 +0200 |
The qmp_tmp105_set_temperature() call will trigger
TempSensorClass::set_temperature(), then hmp_info_temperature()
triggers TempSensorClass::get_temperature().
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
tests/qtest/tmp105-test.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/tests/qtest/tmp105-test.c b/tests/qtest/tmp105-test.c
index f930a96b83..db7e505cbe 100644
--- a/tests/qtest/tmp105-test.c
+++ b/tests/qtest/tmp105-test.c
@@ -41,11 +41,26 @@ static void qmp_tmp105_set_temperature(const char *id, int
value)
qobject_unref(response);
}
+static char *hmp_info_temperature(const char *id)
+{
+ QDict *response;
+ char *output;
+
+ response = qmp("{'execute': 'human-monitor-command',"
+ " 'arguments': {'command-line': 'info temp'}}");
+ g_assert(qdict_haskey(response, "return"));
+ output = g_strdup(qdict_get_try_str(response, "return"));
+ qobject_unref(response);
+
+ return output;
+}
+
#define TMP105_PRECISION (1000/16)
static void send_and_receive(void *obj, void *data, QGuestAllocator *alloc)
{
uint16_t value;
QI2CDevice *i2cdev = (QI2CDevice *)obj;
+ g_autofree char *s = NULL;
value = qmp_tmp105_get_temperature(TMP105_TEST_ID);
g_assert_cmpuint(value, ==, 0);
@@ -56,6 +71,9 @@ static void send_and_receive(void *obj, void *data,
QGuestAllocator *alloc)
qmp_tmp105_set_temperature(TMP105_TEST_ID, 20000);
value = qmp_tmp105_get_temperature(TMP105_TEST_ID);
g_assert_cmpuint(value, ==, 20000);
+ /* Test TempSensorClass via 'info temp' */
+ s = hmp_info_temperature(TMP105_TEST_ID);
+ g_assert(strstr(s, "tmp105-0 20.00"));
value = i2c_get16(i2cdev, TMP105_REG_TEMPERATURE);
g_assert_cmphex(value, ==, 0x1400);
--
2.21.1
- [RFC PATCH 08/17] hw/misc/tmp421: Extract set_temp_mC() helper, (continued)
- [RFC PATCH 08/17] hw/misc/tmp421: Extract set_temp_mC() helper, Philippe Mathieu-Daudé, 2020/04/21
- [RFC PATCH 04/17] hw/misc/tmp105: Extract get_temp_mC() and set_temp_mC() helpers, Philippe Mathieu-Daudé, 2020/04/21
- [RFC PATCH 05/17] hw/misc/tmp105: Implement the 'temperature-sensor' qdev interface, Philippe Mathieu-Daudé, 2020/04/21
- [RFC PATCH 09/17] hw/misc/tmp421: Implement the 'temperature-sensor' qdev interface, Philippe Mathieu-Daudé, 2020/04/21
- [RFC PATCH 10/17] hw/misc/bcm2835_thermal: Hold the temperature in the device state, Philippe Mathieu-Daudé, 2020/04/21
- [RFC PATCH 07/17] hw/misc/tmp421: Extract get_temp_mC() helper, Philippe Mathieu-Daudé, 2020/04/21
- [RFC PATCH 12/17] hw/misc/bcm2835_property: Hold the temperature in the device state, Philippe Mathieu-Daudé, 2020/04/21
- [RFC PATCH 11/17] hw/misc/bcm2835_thermal: Implement the 'temperature-sensor' interface, Philippe Mathieu-Daudé, 2020/04/21
- [RFC PATCH 16/17] hw/misc/imx6ul_ccm: Implement the 'temperature-sensor' qdev interface, Philippe Mathieu-Daudé, 2020/04/21
- [RFC PATCH 14/17] hw/display/ads7846: Implement the 'temperature-sensor' qdev interface, Philippe Mathieu-Daudé, 2020/04/21
- [RFC PATCH 17/17] tests/qtest/tmp105-test: Trivial test for TempSensorClass,
Philippe Mathieu-Daudé <=
- [RFC PATCH 15/17] hw/ide/qdev: Implement the 'temperature-sensor' qdev interface, Philippe Mathieu-Daudé, 2020/04/21
- [RFC PATCH 13/17] hw/misc/bcm2835_property: Implement the 'temperature-sensor' interface, Philippe Mathieu-Daudé, 2020/04/21