Skip to content

Commit 1807cb7

Browse files
committed
Roughing in a test to create the failure described in #221
1 parent 47dcd00 commit 1807cb7

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

nc_test4/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ SET(NC4_TESTS tst_dims tst_dims2 tst_dims3 tst_files tst_files4 tst_vars
99
t_type cdm_sea_soundings tst_vl tst_atts1 tst_atts2
1010
tst_vars2 tst_files5 tst_files6 tst_sync tst_h_strbug tst_h_refs
1111
tst_h_scalar tst_rename tst_h5_endians tst_atts_string_rewrite
12-
tst_put_vars_two_unlim_dim)
12+
tst_put_vars_two_unlim_dim tst_gh221)
1313

1414
# Note, renamegroup needs to be compiled before run_grp_rename
1515
build_bin_test(renamegroup)

nc_test4/tst_gh221.c

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/* This is part of the netCDF package. Copyright 2005 University
2+
Corporation for Atmospheric Research/Unidata See COPYRIGHT file for
3+
conditions of use.
4+
5+
This program excersizes HDF5 variable length array code.
6+
7+
$Id: tst_h_vl2.c,v 1.5 2010/06/01 15:34:52 ed Exp $
8+
*/
9+
#include <nc_tests.h>
10+
#include <hdf5.h>
11+
#include <nc_logging.h>
12+
13+
#define FILE_NAME "tst_gh221.nc"
14+
#define DIM_LEN 3;
15+
#define DIM_NAME "x"
16+
#define VLNE_NAME "vltest"
17+
#define VAR_NAME1 "v"
18+
#define VAR_NAME2 "w"
19+
20+
int main() {
21+
22+
printf("Testing access to unset entrines in VLEN variable\n");
23+
{
24+
int ncid, typeid, dimid;
25+
nc_vlen_t data[DIM_LEN], data_in[DIM_LEN];
26+
27+
size_t size_in;
28+
nc_type base_nc_type_in;
29+
int *phony, class_in;
30+
size_t len_in;
31+
int i, j;
32+
33+
/* Create phony data. */
34+
for (i=0; i<DIM_LEN; i++) {
35+
if (!(phony = malloc(sizeof(int) * (i+1))))
36+
return NC_ENOMEM;
37+
for (j = 0; j < i + 1; j++)
38+
phony[j] = PHONY_VAL;
39+
data[i].p = phony;
40+
data[i].len = i+1;
41+
}
42+
43+
/* Create File */
44+
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
45+
46+
/* Create Dimension */
47+
if (nc_def_dim(ncid, DIM_NAME, DIM_LEN, &dimid)) ERR;
48+
49+
/* Create ragged array type. */
50+
if (nc_def_vlen(ncid, VLEN_NAME, NC_FLOAT, &typeid)) ERR;
51+
52+
/* Create a variable of typeid. */
53+
if (nc_def_var(ncid, VAR_NAME1, typeid, 1, &dimid, &varid);
54+
55+
/* Close File. */
56+
if (nc_close(ncid)) ERR;
57+
58+
59+
60+
}

0 commit comments

Comments
 (0)