LCOV - code coverage report
Current view: top level - tests - test-rcu.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 11 11 100.0 %
Date: 2016-09-14 01:02:56 Functions: 4 4 100.0 %
Branches: 3 6 50.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright (c) 2016 Nicira, Inc.
       3                 :            :  *
       4                 :            :  * Licensed under the Apache License, Version 2.0 (the "License");
       5                 :            :  * you may not use this file except in compliance with the License.
       6                 :            :  * You may obtain a copy of the License at:
       7                 :            :  *
       8                 :            :  *     http://www.apache.org/licenses/LICENSE-2.0
       9                 :            :  *
      10                 :            :  * Unless required by applicable law or agreed to in writing, software
      11                 :            :  * distributed under the License is distributed on an "AS IS" BASIS,
      12                 :            :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      13                 :            :  * See the License for the specific language governing permissions and
      14                 :            :  * limitations under the License.
      15                 :            :  */
      16                 :            : 
      17                 :            : #include <config.h>
      18                 :            : #undef NDEBUG
      19                 :            : #include "fatal-signal.h"
      20                 :            : #include "ovs-rcu.h"
      21                 :            : #include "ovs-thread.h"
      22                 :            : #include "ovstest.h"
      23                 :            : #include "util.h"
      24                 :            : 
      25                 :            : static void *
      26                 :          1 : quiescer_main(void *aux OVS_UNUSED)
      27                 :            : {
      28                 :            :     /* A new thread must be not be quiescent */
      29         [ -  + ]:          1 :     ovs_assert(!ovsrcu_is_quiescent());
      30                 :          1 :     ovsrcu_quiesce_start();
      31                 :            :     /* After the above call it must be quiescent */
      32         [ -  + ]:          1 :     ovs_assert(ovsrcu_is_quiescent());
      33                 :            : 
      34                 :          1 :     return NULL;
      35                 :            : }
      36                 :            : 
      37                 :            : static void
      38                 :          1 : test_rcu_quiesce(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
      39                 :            : {
      40                 :            :     pthread_t quiescer;
      41                 :            : 
      42                 :          1 :     quiescer = ovs_thread_create("quiescer", quiescer_main, NULL);
      43                 :            : 
      44                 :            :     /* This is the main thread of the process. After spawning its first
      45                 :            :      * thread it must not be quiescent. */
      46         [ -  + ]:          1 :     ovs_assert(!ovsrcu_is_quiescent());
      47                 :            : 
      48                 :          1 :     xpthread_join(quiescer, NULL);
      49                 :          1 : }
      50                 :            : 
      51                 :       1176 : OVSTEST_REGISTER("test-rcu-quiesce", test_rcu_quiesce);

Generated by: LCOV version 1.12