Clean up some SonarQube warnings in `service' directory.
[platform/upstream/iotivity.git] / service / protocol-plugin / lib / cpluff / test / psymbolusage.c
1 /*-------------------------------------------------------------------------
2  * C-Pluff, a plug-in framework for C
3  * Copyright 2007 Johannes Lehtinen
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included
13  * in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  *-----------------------------------------------------------------------*/
23
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #include "test.h"
28
29 void symbolusage(void) {
30         cp_context_t *ctx;
31         cp_status_t status;
32         int errors;
33         const char *str;
34
35         ctx = init_context(CP_LOG_ERROR, &errors);
36         check(cp_register_pcollection(ctx, "tmp/install/plugins") == CP_OK);
37         check(cp_scan_plugins(ctx, 0) == CP_OK);
38
39         // Start plug-in implicitly by resolving a symbol
40         check((str = cp_resolve_symbol(ctx, "symuser", "used_string", &status)) != NULL && status == CP_OK);
41
42         // Compare used string to the provided string
43         check(strcmp(str, "Provided string") == 0);
44
45         // Release string
46         cp_release_symbol(ctx, str);
47
48         // Shutdown framework
49         cp_destroy();
50         check(errors == 0);
51 }