]> git.proxmox.com Git - ovs.git/blame - tests/test-rcu.c
Fix ovs-dpctl-top by removing 3 wrong hunks in py3-compat.patch.
[ovs.git] / tests / test-rcu.c
CommitLineData
13b6d087
DDP
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
25static void *
26quiescer_main(void *aux OVS_UNUSED)
27{
28 /* A new thread must be not be quiescent */
29 ovs_assert(!ovsrcu_is_quiescent());
30 ovsrcu_quiesce_start();
31 /* After the above call it must be quiescent */
32 ovs_assert(ovsrcu_is_quiescent());
33
34 return NULL;
35}
36
37static void
38test_rcu_quiesce(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
39{
40 pthread_t quiescer;
41
13b6d087
DDP
42 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 ovs_assert(!ovsrcu_is_quiescent());
47
48 xpthread_join(quiescer, NULL);
49}
50
51OVSTEST_REGISTER("test-rcu-quiesce", test_rcu_quiesce);