Changeset d71d1da in rtems for testsuites


Ignore:
Timestamp:
Feb 2, 2018, 7:00:23 AM (23 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
0c5d22f
Parents:
c1c71cd
git-author:
Sebastian Huber <sebastian.huber@…> (02/02/18 07:00:23)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/02/18 14:01:19)
Message:

spsyslock01: Fix object compare

Due to structure internal padding the use of memcmp() may lead to
sporadic test failures.

Update #3082.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/sptests/spsyslock01/init.c

    rc1c71cd rd71d1da  
    9595}
    9696
     97static bool eq_tq(
     98  const struct _Thread_queue_Queue *a,
     99  const struct _Thread_queue_Queue *b
     100)
     101{
     102  return a->_Lock._next_ticket == b->_Lock._next_ticket
     103    && a->_Lock._now_serving == b->_Lock._now_serving
     104    && a->_heads == b->_heads
     105    && a->_owner == b->_owner
     106    && a->_name == b->_name;
     107}
     108
     109static bool eq_mtx(
     110  const struct _Mutex_Control *a,
     111  const struct _Mutex_Control *b
     112)
     113{
     114  return eq_tq(&a->_Queue, &b->_Queue);
     115}
     116
     117static bool eq_rec_mtx(
     118  const struct _Mutex_recursive_Control *a,
     119  const struct _Mutex_recursive_Control *b
     120)
     121{
     122  return eq_mtx(&a->_Mutex, &b->_Mutex)
     123    && a->_nest_level == b->_nest_level;
     124}
     125
     126static bool eq_cond(
     127  const struct _Condition_Control *a,
     128  const struct _Condition_Control *b
     129)
     130{
     131  return eq_tq(&a->_Queue, &b->_Queue);
     132}
     133
     134static bool eq_sem(
     135  const struct _Semaphore_Control *a,
     136  const struct _Semaphore_Control *b
     137)
     138{
     139  return eq_tq(&a->_Queue, &b->_Queue)
     140    && a->_count == b->_count;
     141}
     142
     143static bool eq_futex(
     144  const struct _Futex_Control *a,
     145  const struct _Futex_Control *b
     146)
     147{
     148  return eq_tq(&a->_Queue, &b->_Queue);
     149}
     150
    97151static void test_initialization(test_context *ctx)
    98152{
     
    109163  _Futex_Initialize(&ctx->futex);
    110164
    111   rtems_test_assert(memcmp(&mtx, &ctx->mtx, sizeof(mtx)) == 0);
    112   rtems_test_assert(memcmp(&rec_mtx, &ctx->rec_mtx, sizeof(rec_mtx)) == 0);
    113   rtems_test_assert(memcmp(&cond, &ctx->cond, sizeof(cond)) == 0);
    114   rtems_test_assert(memcmp(&sem, &ctx->sem, sizeof(sem)) == 0);
    115   rtems_test_assert(memcmp(&futex, &ctx->futex, sizeof(futex)) == 0);
     165  rtems_test_assert(eq_mtx(&mtx, &ctx->mtx));
     166  rtems_test_assert(eq_rec_mtx(&rec_mtx, &ctx->rec_mtx));
     167  rtems_test_assert(eq_cond(&cond, &ctx->cond));
     168  rtems_test_assert(eq_sem(&sem, &ctx->sem));
     169  rtems_test_assert(eq_futex(&futex, &ctx->futex));
    116170
    117171  _Mutex_Destroy(&mtx);
Note: See TracChangeset for help on using the changeset viewer.