README
1Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
2DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3
4This code is free software; you can redistribute it and/or modify it
5under the terms of the GNU General Public License version 2 only, as
6published by the Free Software Foundation.
7
8This code is distributed in the hope that it will be useful, but WITHOUT
9ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11version 2 for more details (a copy is included in the LICENSE file that
12accompanied this code).
13
14You should have received a copy of the GNU General Public License version
152 along with this work; if not, write to the Free Software Foundation,
16Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17
18Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19or visit www.oracle.com if you need additional information or have any
20questions.
21
22---------------------------------------------------------------------------------
23
24This directory contains source files of testbase_nsk native
25framework, which provides support for native tests.
26
27 Source files:
28 nsk_tools.h
29 nsk_tools.c
30
31 Naming conventions:
32 macroses: NSK_*
33 functions: nsk_*
34
35Also this directory provides support for running native threads
36in a platform independent manner.
37
38 Source files:
39 native_thread.h
40 native_thread.c
41
42 Naming conventions:
43 functions: THREAD_*
44
45The following source files declares a set of functions which
46provides support for lists of various objects
47
48 Source files:
49 nsk_list.h
50 nsk_list.c
51
52 Naming conventions:
53 functions: nsk_list_*
54
55---------------------------------------------------------------------------------
56
57nsk_tools.h
58
59Provides functions and macroses for the most usefull actions:
60
61 - print error message with arguments
62
63 NSK_COMPLAINn(format, arg1, ..., argn)
64
65 - print verbose message with arguments
66
67 NSK_DISPLAYn(format, arg1, ..., argn)
68
69 - trace action execution
70
71 NSK_TRACE(action)
72
73 - trace action, check result for true/false and print error if required
74
75 NSK_VERIFY(action)
76 NSK_VERIFY_NEGATIVE(action)
77
78 - set verbose and trace mode of test output
79
80 void nsk_setVerboseMode(int verbose);
81 int nsk_getVerboseMode();
82
83 void nsk_setTraceMode(int mode);
84 int nsk_getTraceMode();
85
86 - miscelaneous functions for printing messages
87 (hidden by above mentioned macroses)
88
89Typical example of using the NSK_VERIFY macro
90for accesing JVM native environment:
91
92 // jvm->GetEnv(jvm, &env, version)
93 if (!NSK_VERIFY(
94 jvm->GetEnv(&env, JNI_VERSION_1_2) == JNI_OK)) {
95 return JNI_ERR;
96 }
97
98For more specific checks in invocations of JNI and JVMTI functions
99use special macroses defined in share/jni and share/jvmti frameworks.
100
101---------------------------------------------------------------------------------
102
103native_thread.h
104
105Provides platform-independent support for running native threads:
106
107 - manage native threads
108
109 void* THREAD_new(PROCEDURE procedure, void* context);
110 void* THREAD_start(void* thread);
111 void THREAD_waitFor(void* thread);
112 void THREAD_sleep(int seconds);
113
114 - get status of native threads
115
116 int THREAD_isStarted(void* thread);
117 int THREAD_hasFinished(void* thread);
118 int THREAD_status(void* thread);
119
120---------------------------------------------------------------------------------
121
122nsk_list.h
123
124Provides support for lists of various objects:
125
126 - managing list
127 const void* nsk_list_Create();
128 int nsk_list_Destroy(const void *plist);
129
130 - managing elements
131 const void* nsk_list_Add(const void *plist, const void *p);
132 int nsk_list_Delete(const void *plist, int ind);
133
134 - getting element info
135 int nsk_list_getCount(const void *plist);
136 const void* nsk_list_Get(const void *plist, int ind);
137
138Typical example:
139
140int TOTAL_COUNT = 10;
141typedef struct recordStruct {
142 int field1;
143 int field2;
144} record;
145
146main() {
147 int i;
148 record *rec;
149 const void *plist;
150
151 /* creating list */
152 plist = nsk_list_create();
153
154 /* adding new elements */
155 for (i = 0; i < TOTAL_COUNT; i ++) {
156 rec = (record *)malloc(sizeof(record));
157 rec->field1 = i;
158 rec->field2 = i * 10;
159 if (!nsk_list_add(plist, rec)) {
160 free((void *)rec);
161 }
162 }
163
164 /* getting elements */
165 for (i = 0; i < TOTAL_COUNT; i ++) {
166 rec = (record *)nsk_list_get(plist, i);
167 printf("%3d %3d\n", rec->field1, rec->field2);
168 }
169
170 /* deleteing elements */
171 for (i = 0; i < TOTAL_COUNT; i ++) {
172 rec = (record *)nsk_list_get(plist, i);
173 free(rec);
174 nsk_list_remove(plist, 0);
175 }
176
177 /* destroying list */
178 nsk_list_destroy(plist);
179
180}
181
182---------------------------------------------------------------------------------
183
184