~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to tests/test-qmp-event.c

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
95
95
   correctness. */
96
96
static void event_test_emit(test_QAPIEvent event, QDict *d, Error **errp)
97
97
{
98
 
    QObject *obj;
99
98
    QDict *t;
100
99
    int64_t s, ms;
101
100
 
102
101
    /* Verify that we have timestamp, then remove it to compare other fields */
103
 
    obj = qdict_get(d, "timestamp");
104
 
    g_assert(obj);
105
 
    t = qobject_to_qdict(obj);
 
102
    t = qdict_get_qdict(d, "timestamp");
106
103
    g_assert(t);
107
 
    obj = qdict_get(t, "seconds");
108
 
    g_assert(obj && qobject_type(obj) == QTYPE_QINT);
109
 
    s = qint_get_int(qobject_to_qint(obj));
110
 
    obj = qdict_get(t, "microseconds");
111
 
    g_assert(obj && qobject_type(obj) == QTYPE_QINT);
112
 
    ms = qint_get_int(qobject_to_qint(obj));
 
104
    s = qdict_get_try_int(t, "seconds", -2);
 
105
    ms = qdict_get_try_int(t, "microseconds", -2);
113
106
    if (s == -1) {
114
107
        g_assert(ms == -1);
115
108
    } else {
 
109
        g_assert(s >= 0);
116
110
        g_assert(ms >= 0 && ms <= 999999);
117
111
    }
118
112
    g_assert(qdict_size(t) == 2);