Repository navigation
Expand file tree
/
Copy pathvdatatest.java
More file actions
154 lines (138 loc) · 3.17 KB
/
Copy pathvdatatest.java
File metadata and controls
154 lines (138 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import ncsa.hdf.h4toh5lib.*;
import ncsa.hdf.h4toh5lib.exceptions.*;
import ncsa.hdf.hdflib.*;
import ncsa.hdf.hdf5lib.*;
public class vdatatest {
private int file_id = -1;
private int h4toh5id = -1;
private boolean initialized = false;
public vdatatest() {};
static public void main( String []args )
{
vdatatest vdt = new vdatatest();
vdt.setup();
boolean r1 = vdt.test1();
vdt.cleanup();
if (r1) {
System.exit(0);
} else {
System.exit(-1);
}
}
/*
* Set up the testfiles and library interfaces.
*
* These are used by all the tests.
*/
public void setup( )
{
try {
file_id = HDFLibrary.Hopen("vdata_lib_test.hdf",
HDFConstants.DFACC_READ);
} catch (HDFException he1) {
System.err.println("Setup: open H interface exception: "+he1);
System.exit( -1);
}
if (file_id == -1) {
System.err.println("Setup: cannot open H interface: "+file_id);
System.exit( -1);
}
boolean status = false;
try {
status = HDFLibrary.Vstart(file_id);
} catch (HDFException he9) {
System.err.println("Setup: open VS interface exception: "+he9);
try {
HDFLibrary.Hclose(file_id);
} catch (HDFException he10) {}
System.exit( -1);
}
if(status == false) {
System.err.println("Setup: open V interface error");
try {
HDFLibrary.Hclose(file_id);
} catch (HDFException he12) {}
System.exit( -1);
}
try {
h4toh5id= h4toh5.H4toh5open("vdata_lib_test.hdf",
"vdata_lib_test.h5");
} catch (H45Exception h45e1) {
System.err.println("Setup: H4toh5open exception "+h45e1);
try {
HDFLibrary.Vend(file_id);
HDFLibrary.Hclose(file_id);
} catch (HDFException he13) {}
System.exit( -1);
}
if(h4toh5id < 0) {
System.err.println("Setup: error returned by H4toh5open: "+h4toh5id);
try {
HDFLibrary.Vend(file_id);
HDFLibrary.Hclose(file_id);
} catch (HDFException he14) {}
System.exit( -1);
}
initialized = true;
}
/*
* Clean up of global objects.
*/
public void cleanup()
{
if (initialized) {
try {
h4toh5.H4toh5close(h4toh5id);
HDFLibrary.Vend(file_id);
HDFLibrary.Hclose(file_id);
} catch (HDFException he) {}
catch (H45Exception h45e) {}
initialized = false;
}
}
private void test1_cleanup() {
// clean up for test 1 here?
// vdata_id
// vgroup_id
// etc.
// VSdetach(vdata_id);
// Vdetach(vgroup_id);
// SDendaccess(sds_id);
// GRendaccess(image_id);
}
/*
* Test batch I: test Vdata conversion
* for the HDF5 objects.
*/
public boolean test1( )
{
int vdata_ref = 2;
int vdata_id = -1;
try {
vdata_id = HDFLibrary.VSattach(file_id,vdata_ref,"r");
} catch (HDFException he3) {
System.err.println("VSgetid exception "+he3);
System.err.println("Test 1: FAIL");
test1_cleanup();
return(false);
}
try {
h4toh5.H4toh5vdata(h4toh5id,vdata_id,"/group1",null,0);
} catch (H45Exception h45e3) {
System.err.println("h4toh5vdata exception "+h45e3);
System.err.println("Test 1: FAIL");
test1_cleanup();
return(false);
}
try {
HDFLibrary.VSdetach(vdata_id);
} catch (HDFException he3_4) {
System.err.println("VSdetach error ");
System.err.println("Test 1: FAIL after test");
return(false);
}
System.out.print("Test Vdata conversion: ");
System.out.println("PASS");
return(true);
}
}