summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
Diffstat (limited to 'Include')
-rw-r--r--Include/Python-ast.h418
-rw-r--r--Include/Python.h3
-rw-r--r--Include/asdl.h54
-rw-r--r--Include/ast.h13
-rw-r--r--Include/code.h73
-rw-r--r--Include/compile.h71
-rw-r--r--Include/pyport.h1
-rw-r--r--Include/pythonrun.h72
-rw-r--r--Include/symtable.h77
9 files changed, 654 insertions, 128 deletions
diff --git a/Include/Python-ast.h b/Include/Python-ast.h
new file mode 100644
index 0000000..0859acf
--- /dev/null
+++ b/Include/Python-ast.h
@@ -0,0 +1,418 @@
+/* File automatically generated by ../Parser/asdl_c.py */
+
+#include "asdl.h"
+
+typedef struct _mod *mod_ty;
+
+typedef struct _stmt *stmt_ty;
+
+typedef struct _expr *expr_ty;
+
+typedef enum _expr_context { Load=1, Store=2, Del=3, AugLoad=4, AugStore=5,
+ Param=6 } expr_context_ty;
+
+typedef struct _slice *slice_ty;
+
+typedef enum _boolop { And=1, Or=2 } boolop_ty;
+
+typedef enum _operator { Add=1, Sub=2, Mult=3, Div=4, Mod=5, Pow=6, LShift=7,
+ RShift=8, BitOr=9, BitXor=10, BitAnd=11, FloorDiv=12 }
+ operator_ty;
+
+typedef enum _unaryop { Invert=1, Not=2, UAdd=3, USub=4 } unaryop_ty;
+
+typedef enum _cmpop { Eq=1, NotEq=2, Lt=3, LtE=4, Gt=5, GtE=6, Is=7, IsNot=8,
+ In=9, NotIn=10 } cmpop_ty;
+
+typedef struct _comprehension *comprehension_ty;
+
+typedef struct _excepthandler *excepthandler_ty;
+
+typedef struct _arguments *arguments_ty;
+
+typedef struct _keyword *keyword_ty;
+
+typedef struct _alias *alias_ty;
+
+struct _mod {
+ enum { Module_kind=1, Interactive_kind=2, Expression_kind=3,
+ Suite_kind=4 } kind;
+ union {
+ struct {
+ asdl_seq *body;
+ } Module;
+
+ struct {
+ asdl_seq *body;
+ } Interactive;
+
+ struct {
+ expr_ty body;
+ } Expression;
+
+ struct {
+ asdl_seq *body;
+ } Suite;
+
+ } v;
+};
+
+struct _stmt {
+ enum { FunctionDef_kind=1, ClassDef_kind=2, Return_kind=3,
+ Delete_kind=4, Assign_kind=5, AugAssign_kind=6, Print_kind=7,
+ For_kind=8, While_kind=9, If_kind=10, Raise_kind=11,
+ TryExcept_kind=12, TryFinally_kind=13, Assert_kind=14,
+ Import_kind=15, ImportFrom_kind=16, Exec_kind=17,
+ Global_kind=18, Expr_kind=19, Pass_kind=20, Break_kind=21,
+ Continue_kind=22 } kind;
+ union {
+ struct {
+ identifier name;
+ arguments_ty args;
+ asdl_seq *body;
+ asdl_seq *decorators;
+ } FunctionDef;
+
+ struct {
+ identifier name;
+ asdl_seq *bases;
+ asdl_seq *body;
+ } ClassDef;
+
+ struct {
+ expr_ty value;
+ } Return;
+
+ struct {
+ asdl_seq *targets;
+ } Delete;
+
+ struct {
+ asdl_seq *targets;
+ expr_ty value;
+ } Assign;
+
+ struct {
+ expr_ty target;
+ operator_ty op;
+ expr_ty value;
+ } AugAssign;
+
+ struct {
+ expr_ty dest;
+ asdl_seq *values;
+ bool nl;
+ } Print;
+
+ struct {
+ expr_ty target;
+ expr_ty iter;
+ asdl_seq *body;
+ asdl_seq *orelse;
+ } For;
+
+ struct {
+ expr_ty test;
+ asdl_seq *body;
+ asdl_seq *orelse;
+ } While;
+
+ struct {
+ expr_ty test;
+ asdl_seq *body;
+ asdl_seq *orelse;
+ } If;
+
+ struct {
+ expr_ty type;
+ expr_ty inst;
+ expr_ty tback;
+ } Raise;
+
+ struct {
+ asdl_seq *body;
+ asdl_seq *handlers;
+ asdl_seq *orelse;
+ } TryExcept;
+
+ struct {
+ asdl_seq *body;
+ asdl_seq *finalbody;
+ } TryFinally;
+
+ struct {
+ expr_ty test;
+ expr_ty msg;
+ } Assert;
+
+ struct {
+ asdl_seq *names;
+ } Import;
+
+ struct {
+ identifier module;
+ asdl_seq *names;
+ } ImportFrom;
+
+ struct {
+ expr_ty body;
+ expr_ty globals;
+ expr_ty locals;
+ } Exec;
+
+ struct {
+ asdl_seq *names;
+ } Global;
+
+ struct {
+ expr_ty value;
+ } Expr;
+
+ } v;
+ int lineno;
+};
+
+struct _expr {
+ enum { BoolOp_kind=1, BinOp_kind=2, UnaryOp_kind=3, Lambda_kind=4,
+ Dict_kind=5, ListComp_kind=6, GeneratorExp_kind=7, Yield_kind=8,
+ Compare_kind=9, Call_kind=10, Repr_kind=11, Num_kind=12,
+ Str_kind=13, Attribute_kind=14, Subscript_kind=15, Name_kind=16,
+ List_kind=17, Tuple_kind=18 } kind;
+ union {
+ struct {
+ boolop_ty op;
+ asdl_seq *values;
+ } BoolOp;
+
+ struct {
+ expr_ty left;
+ operator_ty op;
+ expr_ty right;
+ } BinOp;
+
+ struct {
+ unaryop_ty op;
+ expr_ty operand;
+ } UnaryOp;
+
+ struct {
+ arguments_ty args;
+ expr_ty body;
+ } Lambda;
+
+ struct {
+ asdl_seq *keys;
+ asdl_seq *values;
+ } Dict;
+
+ struct {
+ expr_ty elt;
+ asdl_seq *generators;
+ } ListComp;
+
+ struct {
+ expr_ty elt;
+ asdl_seq *generators;
+ } GeneratorExp;
+
+ struct {
+ expr_ty value;
+ } Yield;
+
+ struct {
+ expr_ty left;
+ asdl_seq *ops;
+ asdl_seq *comparators;
+ } Compare;
+
+ struct {
+ expr_ty func;
+ asdl_seq *args;
+ asdl_seq *keywords;
+ expr_ty starargs;
+ expr_ty kwargs;
+ } Call;
+
+ struct {
+ expr_ty value;
+ } Repr;
+
+ struct {
+ object n;
+ } Num;
+
+ struct {
+ string s;
+ } Str;
+
+ struct {
+ expr_ty value;
+ identifier attr;
+ expr_context_ty ctx;
+ } Attribute;
+
+ struct {
+ expr_ty value;
+ slice_ty slice;
+ expr_context_ty ctx;
+ } Subscript;
+
+ struct {
+ identifier id;
+ expr_context_ty ctx;
+ } Name;
+
+ struct {
+ asdl_seq *elts;
+ expr_context_ty ctx;
+ } List;
+
+ struct {
+ asdl_seq *elts;
+ expr_context_ty ctx;
+ } Tuple;
+
+ } v;
+ int lineno;
+};
+
+struct _slice {
+ enum { Ellipsis_kind=1, Slice_kind=2, ExtSlice_kind=3, Index_kind=4 }
+ kind;
+ union {
+ struct {
+ expr_ty lower;
+ expr_ty upper;
+ expr_ty step;
+ } Slice;
+
+ struct {
+ asdl_seq *dims;
+ } ExtSlice;
+
+ struct {
+ expr_ty value;
+ } Index;
+
+ } v;
+};
+
+struct _comprehension {
+ expr_ty target;
+ expr_ty iter;
+ asdl_seq *ifs;
+};
+
+struct _excepthandler {
+ expr_ty type;
+ expr_ty name;
+ asdl_seq *body;
+};
+
+struct _arguments {
+ asdl_seq *args;
+ identifier vararg;
+ identifier kwarg;
+ asdl_seq *defaults;
+};
+
+struct _keyword {
+ identifier arg;
+ expr_ty value;
+};
+
+struct _alias {
+ identifier name;
+ identifier asname;
+};
+
+mod_ty Module(asdl_seq * body);
+mod_ty Interactive(asdl_seq * body);
+mod_ty Expression(expr_ty body);
+mod_ty Suite(asdl_seq * body);
+stmt_ty FunctionDef(identifier name, arguments_ty args, asdl_seq * body,
+ asdl_seq * decorators, int lineno);
+stmt_ty ClassDef(identifier name, asdl_seq * bases, asdl_seq * body, int
+ lineno);
+stmt_ty Return(expr_ty value, int lineno);
+stmt_ty Delete(asdl_seq * targets, int lineno);
+stmt_ty Assign(asdl_seq * targets, expr_ty value, int lineno);
+stmt_ty AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno);
+stmt_ty Print(expr_ty dest, asdl_seq * values, bool nl, int lineno);
+stmt_ty For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * orelse,
+ int lineno);
+stmt_ty While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno);
+stmt_ty If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno);
+stmt_ty Raise(expr_ty type, expr_ty inst, expr_ty tback, int lineno);
+stmt_ty TryExcept(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, int
+ lineno);
+stmt_ty TryFinally(asdl_seq * body, asdl_seq * finalbody, int lineno);
+stmt_ty Assert(expr_ty test, expr_ty msg, int lineno);
+stmt_ty Import(asdl_seq * names, int lineno);
+stmt_ty ImportFrom(identifier module, asdl_seq * names, int lineno);
+stmt_ty Exec(expr_ty body, expr_ty globals, expr_ty locals, int lineno);
+stmt_ty Global(asdl_seq * names, int lineno);
+stmt_ty Expr(expr_ty value, int lineno);
+stmt_ty Pass(int lineno);
+stmt_ty Break(int lineno);
+stmt_ty Continue(int lineno);
+expr_ty BoolOp(boolop_ty op, asdl_seq * values, int lineno);
+expr_ty BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno);
+expr_ty UnaryOp(unaryop_ty op, expr_ty operand, int lineno);
+expr_ty Lambda(arguments_ty args, expr_ty body, int lineno);
+expr_ty Dict(asdl_seq * keys, asdl_seq * values, int lineno);
+expr_ty ListComp(expr_ty elt, asdl_seq * generators, int lineno);
+expr_ty GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno);
+expr_ty Yield(expr_ty value, int lineno);
+expr_ty Compare(expr_ty left, asdl_seq * ops, asdl_seq * comparators, int
+ lineno);
+expr_ty Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty
+ starargs, expr_ty kwargs, int lineno);
+expr_ty Repr(expr_ty value, int lineno);
+expr_ty Num(object n, int lineno);
+expr_ty Str(string s, int lineno);
+expr_ty Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int
+ lineno);
+expr_ty Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int
+ lineno);
+expr_ty Name(identifier id, expr_context_ty ctx, int lineno);
+expr_ty List(asdl_seq * elts, expr_context_ty ctx, int lineno);
+expr_ty Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno);
+slice_ty Ellipsis(void);
+slice_ty Slice(expr_ty lower, expr_ty upper, expr_ty step);
+slice_ty ExtSlice(asdl_seq * dims);
+slice_ty Index(expr_ty value);
+comprehension_ty comprehension(expr_ty target, expr_ty iter, asdl_seq * ifs);
+excepthandler_ty excepthandler(expr_ty type, expr_ty name, asdl_seq * body);
+arguments_ty arguments(asdl_seq * args, identifier vararg, identifier kwarg,
+ asdl_seq * defaults);
+keyword_ty keyword(identifier arg, expr_ty value);
+alias_ty alias(identifier name, identifier asname);
+void free_mod(mod_ty);
+void free_stmt(stmt_ty);
+void free_expr(expr_ty);
+void free_expr_context(expr_context_ty);
+void free_slice(slice_ty);
+void free_boolop(boolop_ty);
+void free_operator(operator_ty);
+void free_unaryop(unaryop_ty);
+void free_cmpop(cmpop_ty);
+void free_comprehension(comprehension_ty);
+void free_excepthandler(excepthandler_ty);
+void free_arguments(arguments_ty);
+void free_keyword(keyword_ty);
+void free_alias(alias_ty);
+int marshal_write_mod(PyObject **, int *, mod_ty);
+int marshal_write_stmt(PyObject **, int *, stmt_ty);
+int marshal_write_expr(PyObject **, int *, expr_ty);
+int marshal_write_expr_context(PyObject **, int *, expr_context_ty);
+int marshal_write_slice(PyObject **, int *, slice_ty);
+int marshal_write_boolop(PyObject **, int *, boolop_ty);
+int marshal_write_operator(PyObject **, int *, operator_ty);
+int marshal_write_unaryop(PyObject **, int *, unaryop_ty);
+int marshal_write_cmpop(PyObject **, int *, cmpop_ty);
+int marshal_write_comprehension(PyObject **, int *, comprehension_ty);
+int marshal_write_excepthandler(PyObject **, int *, excepthandler_ty);
+int marshal_write_arguments(PyObject **, int *, arguments_ty);
+int marshal_write_keyword(PyObject **, int *, keyword_ty);
+int marshal_write_alias(PyObject **, int *, alias_ty);
diff --git a/Include/Python.h b/Include/Python.h
index 2d48d2e..f941cba 100644
--- a/Include/Python.h
+++ b/Include/Python.h
@@ -128,8 +128,7 @@
#include "pystrtod.h"
/* _Py_Mangle is defined in compile.c */
-PyAPI_FUNC(int) _Py_Mangle(char *p, char *name, \
- char *buffer, size_t maxlen);
+PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);
/* PyArg_GetInt is deprecated and should not be used, use PyArg_Parse(). */
#define PyArg_GetInt(v, a) PyArg_Parse((v), "i", (a))
diff --git a/Include/asdl.h b/Include/asdl.h
new file mode 100644
index 0000000..8ad46fa
--- /dev/null
+++ b/Include/asdl.h
@@ -0,0 +1,54 @@
+#ifndef Py_ASDL_H
+#define Py_ASDL_H
+
+typedef PyObject * identifier;
+typedef PyObject * string;
+typedef PyObject * object;
+
+typedef enum {false, true} bool;
+
+/* It would be nice if the code generated by asdl_c.py was completely
+ independent of Python, but it is a goal the requires too much work
+ at this stage. So, for example, I'll represent identifiers as
+ interned Python strings.
+*/
+
+/* XXX A sequence should be typed so that its use can be typechecked. */
+
+/* XXX We shouldn't pay for offset when we don't need APPEND. */
+
+typedef struct {
+ int size;
+ int offset;
+ void *elements[1];
+} asdl_seq;
+
+asdl_seq *asdl_seq_new(int size);
+void asdl_seq_free(asdl_seq *);
+
+#ifdef Py_DEBUG
+#define asdl_seq_GET(S, I) (S)->elements[(I)]
+#define asdl_seq_SET(S, I, V) { \
+ int _asdl_i = (I); \
+ assert((S) && _asdl_i < (S)->size); \
+ (S)->elements[_asdl_i] = (V); \
+}
+#define asdl_seq_APPEND(S, V) { \
+ assert((S) && (S)->offset < (S)->size); \
+ (S)->elements[(S)->offset++] = (V); \
+}
+#else
+#define asdl_seq_GET(S, I) (S)->elements[(I)]
+#define asdl_seq_SET(S, I, V) (S)->elements[I] = (V)
+#define asdl_seq_APPEND(S, V) (S)->elements[(S)->offset++] = (V)
+#endif
+#define asdl_seq_LEN(S) ((S) == NULL ? 0 : (S)->size)
+
+/* Routines to marshal the basic types. */
+int marshal_write_int(PyObject **, int *, int);
+int marshal_write_bool(PyObject **, int *, bool);
+int marshal_write_identifier(PyObject **, int *, identifier);
+int marshal_write_string(PyObject **, int *, string);
+int marshal_write_object(PyObject **, int *, object);
+
+#endif /* !Py_ASDL_H */
diff --git a/Include/ast.h b/Include/ast.h
new file mode 100644
index 0000000..8912f38
--- /dev/null
+++ b/Include/ast.h
@@ -0,0 +1,13 @@
+#ifndef Py_AST_H
+#define Py_AST_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern DL_IMPORT(mod_ty) PyAST_FromNode(const node *, PyCompilerFlags *flags,
+ const char *);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !Py_AST_H */
diff --git a/Include/code.h b/Include/code.h
new file mode 100644
index 0000000..e6478b0
--- /dev/null
+++ b/Include/code.h
@@ -0,0 +1,73 @@
+/* Definitions for bytecode */
+
+#ifndef Py_CODE_H
+#define Py_CODE_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Bytecode object */
+typedef struct {
+ PyObject_HEAD
+ int co_argcount; /* #arguments, except *args */
+ int co_nlocals; /* #local variables */
+ int co_stacksize; /* #entries needed for evaluation stack */
+ int co_flags; /* CO_..., see below */
+ PyObject *co_code; /* instruction opcodes */
+ PyObject *co_consts; /* list (constants used) */
+ PyObject *co_names; /* list of strings (names used) */
+ PyObject *co_varnames; /* tuple of strings (local variable names) */
+ PyObject *co_freevars; /* tuple of strings (free variable names) */
+ PyObject *co_cellvars; /* tuple of strings (cell variable names) */
+ /* The rest doesn't count for hash/cmp */
+ PyObject *co_filename; /* string (where it was loaded from) */
+ PyObject *co_name; /* string (name, for reference) */
+ int co_firstlineno; /* first source line number */
+ PyObject *co_lnotab; /* string (encoding addr<->lineno mapping) */
+} PyCodeObject;
+
+/* Masks for co_flags above */
+#define CO_OPTIMIZED 0x0001
+#define CO_NEWLOCALS 0x0002
+#define CO_VARARGS 0x0004
+#define CO_VARKEYWORDS 0x0008
+#define CO_NESTED 0x0010
+#define CO_GENERATOR 0x0020
+/* The CO_NOFREE flag is set if there are no free or cell variables.
+ This information is redundant, but it allows a single flag test
+ to determine whether there is any extra work to be done when the
+ call frame it setup.
+*/
+#define CO_NOFREE 0x0040
+/* XXX Temporary hack. Until generators are a permanent part of the
+ language, we need a way for a code object to record that generators
+ were *possible* when it was compiled. This is so code dynamically
+ compiled *by* a code object knows whether to allow yield stmts. In
+ effect, this passes on the "from __future__ import generators" state
+ in effect when the code block was compiled. */
+#define CO_GENERATOR_ALLOWED 0x1000 /* no longer used in an essential way */
+#define CO_FUTURE_DIVISION 0x2000
+
+#define CO_MAXBLOCKS 20 /* Max static block nesting within a function */
+
+extern DL_IMPORT(PyTypeObject) PyCode_Type;
+
+#define PyCode_Check(op) ((op)->ob_type == &PyCode_Type)
+#define PyCode_GetNumFree(op) (PyTuple_GET_SIZE((op)->co_freevars))
+
+/* Public interface */
+DL_IMPORT(PyCodeObject *) PyCode_New(
+ int, int, int, int, PyObject *, PyObject *, PyObject *, PyObject *,
+ PyObject *, PyObject *, PyObject *, PyObject *, int, PyObject *);
+ /* same as struct above */
+DL_IMPORT(int) PyCode_Addr2Line(PyCodeObject *, int);
+
+/* for internal use only */
+#define _PyCode_GETCODEPTR(co, pp) \
+ ((*(co)->co_code->ob_type->tp_as_buffer->bf_getreadbuffer) \
+ ((co)->co_code, 0, (void **)(pp)))
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !Py_CODE_H */
diff --git a/Include/compile.h b/Include/compile.h
index 82bf708..27a3f76 100644
--- a/Include/compile.h
+++ b/Include/compile.h
@@ -1,5 +1,6 @@
-
-/* Definitions for bytecode */
+#ifndef Py_CODE_H
+#include "code.h"
+#endif
#ifndef Py_COMPILE_H
#define Py_COMPILE_H
@@ -7,55 +8,6 @@
extern "C" {
#endif
-/* Bytecode object */
-typedef struct {
- PyObject_HEAD
- int co_argcount; /* #arguments, except *args */
- int co_nlocals; /* #local variables */
- int co_stacksize; /* #entries needed for evaluation stack */
- int co_flags; /* CO_..., see below */
- PyObject *co_code; /* instruction opcodes */
- PyObject *co_consts; /* list (constants used) */
- PyObject *co_names; /* list of strings (names used) */
- PyObject *co_varnames; /* tuple of strings (local variable names) */
- PyObject *co_freevars; /* tuple of strings (free variable names) */
- PyObject *co_cellvars; /* tuple of strings (cell variable names) */
- /* The rest doesn't count for hash/cmp */
- PyObject *co_filename; /* string (where it was loaded from) */
- PyObject *co_name; /* string (name, for reference) */
- int co_firstlineno; /* first source line number */
- PyObject *co_lnotab; /* string (encoding addr<->lineno mapping) */
-} PyCodeObject;
-
-/* Masks for co_flags above */
-#define CO_OPTIMIZED 0x0001
-#define CO_NEWLOCALS 0x0002
-#define CO_VARARGS 0x0004
-#define CO_VARKEYWORDS 0x0008
-#define CO_NESTED 0x0010
-#define CO_GENERATOR 0x0020
-/* The CO_NOFREE flag is set if there are no free or cell variables.
- This information is redundant, but it allows a single flag test
- to determine whether there is any extra work to be done when the
- call frame it setup.
-*/
-#define CO_NOFREE 0x0040
-/* XXX Temporary hack. Until generators are a permanent part of the
- language, we need a way for a code object to record that generators
- were *possible* when it was compiled. This is so code dynamically
- compiled *by* a code object knows whether to allow yield stmts. In
- effect, this passes on the "from __future__ import generators" state
- in effect when the code block was compiled. */
-#define CO_GENERATOR_ALLOWED 0x1000 /* no longer used in an essential way */
-#define CO_FUTURE_DIVISION 0x2000
-
-PyAPI_DATA(PyTypeObject) PyCode_Type;
-
-#define PyCode_Check(op) ((op)->ob_type == &PyCode_Type)
-#define PyCode_GetNumFree(op) (PyTuple_GET_SIZE((op)->co_freevars))
-
-#define CO_MAXBLOCKS 20 /* Max static block nesting within a function */
-
/* Public interface */
struct _node; /* Declare the existence of this type */
PyAPI_FUNC(PyCodeObject *) PyNode_Compile(struct _node *, const char *);
@@ -68,19 +20,22 @@ PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int);
/* Future feature support */
typedef struct {
- int ff_found_docstring;
- int ff_last_lineno;
- int ff_features;
+ int ff_features; /* flags set by future statements */
+ int ff_lineno; /* line number of last future statement */
} PyFutureFeatures;
-PyAPI_FUNC(PyFutureFeatures *) PyNode_Future(struct _node *, const char *);
-PyAPI_FUNC(PyCodeObject *) PyNode_CompileFlags(struct _node *, const char *,
- PyCompilerFlags *);
-
#define FUTURE_NESTED_SCOPES "nested_scopes"
#define FUTURE_GENERATORS "generators"
#define FUTURE_DIVISION "division"
+struct _mod; /* Declare the existence of this type */
+DL_IMPORT(PyCodeObject *) PyAST_Compile(struct _mod *, const char *,
+ PyCompilerFlags *);
+DL_IMPORT(PyFutureFeatures *) PyFuture_FromAST(struct _mod *, const char *);
+
+#define ERR_LATE_FUTURE \
+"from __future__ imports must occur at the beginning of the file"
+
#ifdef __cplusplus
}
#endif
diff --git a/Include/pyport.h b/Include/pyport.h
index 2440c55..ea2091b 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -583,6 +583,7 @@ typedef struct fd_set {
#ifndef INT_MAX
#define INT_MAX 2147483647
+#define INT_MIN (-INT_MAX - 1)
#endif
#ifndef LONG_MAX
diff --git a/Include/pythonrun.h b/Include/pythonrun.h
index f461d13..490613e 100644
--- a/Include/pythonrun.h
+++ b/Include/pythonrun.h
@@ -29,46 +29,37 @@ PyAPI_FUNC(int) Py_IsInitialized(void);
PyAPI_FUNC(PyThreadState *) Py_NewInterpreter(void);
PyAPI_FUNC(void) Py_EndInterpreter(PyThreadState *);
-PyAPI_FUNC(int) PyRun_AnyFile(FILE *, const char *);
-PyAPI_FUNC(int) PyRun_AnyFileEx(FILE *, const char *, int);
-
-PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
-PyAPI_FUNC(int) PyRun_AnyFileExFlags(FILE *, const char *, int, PyCompilerFlags *);
-
-PyAPI_FUNC(int) PyRun_SimpleString(const char *);
+PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, char *, PyCompilerFlags *);
+PyAPI_FUNC(int) PyRun_AnyFileExFlags(FILE *, char *, int, PyCompilerFlags *);
PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *);
-PyAPI_FUNC(int) PyRun_SimpleFile(FILE *, const char *);
-PyAPI_FUNC(int) PyRun_SimpleFileEx(FILE *, const char *, int);
PyAPI_FUNC(int) PyRun_SimpleFileExFlags(FILE *, const char *, int, PyCompilerFlags *);
-PyAPI_FUNC(int) PyRun_InteractiveOne(FILE *, const char *);
PyAPI_FUNC(int) PyRun_InteractiveOneFlags(FILE *, const char *, PyCompilerFlags *);
-PyAPI_FUNC(int) PyRun_InteractiveLoop(FILE *, const char *);
PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(FILE *, const char *, PyCompilerFlags *);
-PyAPI_FUNC(struct _node *) PyParser_SimpleParseString(const char *, int);
-PyAPI_FUNC(struct _node *) PyParser_SimpleParseFile(FILE *, const char *, int);
-PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlags(const char *, int, int);
-PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlagsFilename(const char *,
- const char *,
- int,
- int);
+PyAPI_FUNC(struct _mod *) PyParser_ASTFromString(const char *, const char *,
+ int, PyCompilerFlags *flags);
+PyAPI_FUNC(struct _mod *) PyParser_ASTFromFile(FILE *, const char *, int,
+ char *, char *,
+ PyCompilerFlags *, int *);
+#define PyParser_SimpleParseString(S, B) \
+ PyParser_SimpleParseStringFlags(S, B, 0)
+#define PyParser_SimpleParseFile(FP, S, B) \
+ PyParser_SimpleParseFileFlags(FP, S, B, 0)
+PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlags(const char *, int,
+ int);
PyAPI_FUNC(struct _node *) PyParser_SimpleParseFileFlags(FILE *, const char *,
int, int);
-PyAPI_FUNC(PyObject *) PyRun_String(const char *, int, PyObject *, PyObject *);
-PyAPI_FUNC(PyObject *) PyRun_File(FILE *, const char *, int, PyObject *, PyObject *);
-PyAPI_FUNC(PyObject *) PyRun_FileEx(FILE *, const char *, int,
- PyObject *, PyObject *, int);
-PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *, PyObject *,
- PyCompilerFlags *);
-PyAPI_FUNC(PyObject *) PyRun_FileFlags(FILE *, const char *, int, PyObject *,
- PyObject *, PyCompilerFlags *);
-PyAPI_FUNC(PyObject *) PyRun_FileExFlags(FILE *, const char *, int, PyObject *,
- PyObject *, int, PyCompilerFlags *);
-
-PyAPI_FUNC(PyObject *) Py_CompileString(const char *, const char *, int);
+PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *,
+ PyObject *, PyCompilerFlags *);
+
+PyAPI_FUNC(PyObject *) PyRun_FileExFlags(FILE *, const char *, int,
+ PyObject *, PyObject *, int,
+ PyCompilerFlags *);
+
+#define Py_CompileString(str, p, s) Py_CompileStringFlags(str, p, s, NULL)
PyAPI_FUNC(PyObject *) Py_CompileStringFlags(const char *, const char *, int,
- PyCompilerFlags *);
+ PyCompilerFlags *);
PyAPI_FUNC(struct symtable *) Py_SymtableString(const char *, const char *, int);
PyAPI_FUNC(void) PyErr_Print(void);
@@ -84,6 +75,25 @@ PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *);
/* Bootstrap */
PyAPI_FUNC(int) Py_Main(int argc, char **argv);
+/* Use macros for a bunch of old variants */
+#define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL)
+#define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags(fp, name, 0, NULL)
+#define PyRun_AnyFileEx(fp, name, closeit) \
+ PyRun_AnyFileExFlags(fp, name, closeit, NULL)
+#define PyRun_AnyFileFlags(fp, name, flags) \
+ PyRun_AnyFileExFlags(fp, name, 0, flags)
+#define PyRun_SimpleString(s, f) PyRunSimpleStringFlags(s, f, NULL)
+#define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags(f, p, 0, NULL)
+#define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags(f, p, c, NULL)
+#define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags(f, p, NULL)
+#define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags(f, p, NULL)
+#define PyRun_File(fp, p, s, g, l) \
+ PyRun_FileExFlags(fp, p, s, g, l, 0, NULL)
+#define PyRun_FileEx(fp, p, s, g, l, c) \
+ PyRun_FileExFlags(fp, p, s, g, l, c, NULL)
+#define PyRun_FileFlags(fp, p, s, g, l, flags) \
+ PyRun_FileExFlags(fp, p, s, g, l, 0, flags)
+
/* In getpath.c */
PyAPI_FUNC(char *) Py_GetProgramFullPath(void);
PyAPI_FUNC(char *) Py_GetPrefix(void);
diff --git a/Include/symtable.h b/Include/symtable.h
index 628c3e6..646602c 100644
--- a/Include/symtable.h
+++ b/Include/symtable.h
@@ -4,64 +4,59 @@
extern "C" {
#endif
-/* A symbol table is constructed each time PyNode_Compile() is
- called. The table walks the entire parse tree and identifies each
- use or definition of a variable.
-
- The symbol table contains a dictionary for each code block in a
- module: The symbol dictionary for the block. They keys of these
- dictionaries are the name of all variables used or defined in the
- block; the integer values are used to store several flags,
- e.g. DEF_PARAM indicates that a variable is a parameter to a
- function.
-*/
+typedef enum _block_type { FunctionBlock, ClassBlock, ModuleBlock }
+ block_ty;
struct _symtable_entry;
struct symtable {
- int st_pass; /* pass == 1 or 2 */
const char *st_filename; /* name of file being compiled */
struct _symtable_entry *st_cur; /* current symbol table entry */
+ struct _symtable_entry *st_top; /* module entry */
PyObject *st_symbols; /* dictionary of symbol table entries */
PyObject *st_stack; /* stack of namespace info */
PyObject *st_global; /* borrowed ref to MODULE in st_symbols */
- int st_nscopes; /* number of scopes */
- int st_errors; /* number of errors */
+ int st_nblocks; /* number of blocks */
char *st_private; /* name of current class or NULL */
+ int st_tmpname; /* temporary name counter */
PyFutureFeatures *st_future; /* module's future features */
};
typedef struct _symtable_entry {
PyObject_HEAD
- PyObject *ste_id; /* int: key in st_symbols) */
- PyObject *ste_symbols; /* dict: name to flags) */
- PyObject *ste_name; /* string: name of scope */
+ PyObject *ste_id; /* int: key in st_symbols */
+ PyObject *ste_symbols; /* dict: name to flags */
+ PyObject *ste_name; /* string: name of block */
PyObject *ste_varnames; /* list of variable names */
PyObject *ste_children; /* list of child ids */
- int ste_type; /* module, class, or function */
- int ste_lineno; /* first line of scope */
- int ste_optimized; /* true if namespace can't be optimized */
- int ste_nested; /* true if scope is nested */
- int ste_child_free; /* true if a child scope has free variables,
+ block_ty ste_type; /* module, class, or function */
+ int ste_unoptimized; /* false if namespace is optimized */
+ int ste_nested : 1; /* true if block is nested */
+ int ste_free : 1; /* true if block has free variables */
+ int ste_child_free : 1; /* true if a child block has free variables,
including free refs to globals */
- int ste_generator; /* true if namespace is a generator */
+ int ste_generator : 1; /* true if namespace is a generator */
+ int ste_varargs : 1; /* true if block has varargs */
+ int ste_varkeywords : 1; /* true if block has varkeywords */
+ int ste_lineno; /* first line of block */
int ste_opt_lineno; /* lineno of last exec or import * */
- int ste_tmpname; /* temporary name counter */
+ int ste_tmpname; /* counter for listcomp temp vars */
struct symtable *ste_table;
-} PySymtableEntryObject;
-
-PyAPI_DATA(PyTypeObject) PySymtableEntry_Type;
+} PySTEntryObject;
-#define PySymtableEntry_Check(op) ((op)->ob_type == &PySymtableEntry_Type)
+PyAPI_DATA(PyTypeObject) PySTEntry_Type;
-PyAPI_FUNC(PyObject *) PySymtableEntry_New(struct symtable *,
- char *, int, int);
+#define PySTEntry_Check(op) ((op)->ob_type == &PySTEntry_Type)
-PyAPI_FUNC(struct symtable *) PyNode_CompileSymtable(struct _node *, const char *);
-PyAPI_FUNC(void) PySymtable_Free(struct symtable *);
+PyAPI_FUNC(PySTEntryObject *) \
+ PySTEntry_New(struct symtable *, identifier, block_ty, void *, int);
+PyAPI_FUNC(int) PyST_GetScope(PySTEntryObject *, PyObject *);
+PyAPI_FUNC(struct symtable *) PySymtable_Build(mod_ty, const char *,
+ PyFutureFeatures *);
+PyAPI_FUNC(PySTEntryObject *) PySymtable_Lookup(struct symtable *, void *);
-#define TOP "global"
+PyAPI_FUNC(void) PySymtable_Free(struct symtable *);
/* Flags for def-use information */
@@ -72,16 +67,19 @@ PyAPI_FUNC(void) PySymtable_Free(struct symtable *);
#define DEF_STAR 2<<3 /* parameter is star arg */
#define DEF_DOUBLESTAR 2<<4 /* parameter is star-star arg */
#define DEF_INTUPLE 2<<5 /* name defined in tuple in parameters */
-#define DEF_FREE 2<<6 /* name used but not defined in nested scope */
+#define DEF_FREE 2<<6 /* name used but not defined in nested block */
#define DEF_FREE_GLOBAL 2<<7 /* free variable is actually implicit global */
#define DEF_FREE_CLASS 2<<8 /* free variable from class's method */
#define DEF_IMPORT 2<<9 /* assignment occurred via import */
#define DEF_BOUND (DEF_LOCAL | DEF_PARAM | DEF_IMPORT)
-#define TYPE_FUNCTION 1
-#define TYPE_CLASS 2
-#define TYPE_MODULE 3
+/* GLOBAL_EXPLICIT and GLOBAL_IMPLICIT are used internally by the symbol
+ table. GLOBAL is returned from PyST_GetScope() for either of them.
+ It is stored in ste_symbols at bits 12-14.
+*/
+#define SCOPE_OFF 11
+#define SCOPE_MASK 7
#define LOCAL 1
#define GLOBAL_EXPLICIT 2
@@ -89,9 +87,14 @@ PyAPI_FUNC(void) PySymtable_Free(struct symtable *);
#define FREE 4
#define CELL 5
+/* The following three names are used for the ste_unoptimized bit field */
#define OPT_IMPORT_STAR 1
#define OPT_EXEC 2
#define OPT_BARE_EXEC 4
+#define OPT_TOPLEVEL 8 /* top-level names, including eval and exec */
+
+#define GENERATOR 1
+#define GENERATOR_EXPRESSION 2
#define GENERATOR 1
#define GENERATOR_EXPRESSION 2
t create empty compound data type.\n");
- }
- goto error;
- }
-
- /* Add a coupld fields */
- status = H5Tinsert (complex_id, "real", HOFFSET (tmp, re),
- H5T_NATIVE_DOUBLE);
- if (status<0) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Cannot insert real component.\n");
- }
- goto error;
- }
-
- status = H5Tinsert (complex_id, "imaginary", HOFFSET (tmp, im),
- H5T_NATIVE_DOUBLE);
- if (status<0) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Cannot insert imaginary component.\n");
- }
- goto error;
- }
-
- puts (" PASSED");
-
- /* Just for debugging... */
- H5T_debug (H5Aatom_object (complex_id), stdout);
- printf ("\n");
-
-
- return SUCCEED;
-
- error:
- return FAIL;
+ complex_t tmp;
+ hid_t complex_id;
+ herr_t status;
+
+ printf("%-70s", "Testing compound data types");
+
+ /* Create the empty type */
+ complex_id = H5Tcreate(H5T_COMPOUND, sizeof tmp);
+ if (complex_id < 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Cannot create empty compound data type.\n");
+ }
+ goto error;
+ }
+ /* Add a coupld fields */
+ status = H5Tinsert(complex_id, "real", HOFFSET(tmp, re),
+ H5T_NATIVE_DOUBLE);
+ if (status < 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Cannot insert real component.\n");
+ }
+ goto error;
+ }
+ status = H5Tinsert(complex_id, "imaginary", HOFFSET(tmp, im),
+ H5T_NATIVE_DOUBLE);
+ if (status < 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Cannot insert imaginary component.\n");
+ }
+ goto error;
+ }
+ puts(" PASSED");
+
+ /* Just for debugging... */
+ H5T_debug(H5Aatom_object(complex_id), stdout);
+ printf("\n");
+
+ return SUCCEED;
+
+ error:
+ return FAIL;
}
-
-
-
-
/*-------------------------------------------------------------------------
- * Function: main
+ * Function: main
*
- * Purpose: Test the data type interface.
+ * Purpose: Test the data type interface.
*
- * Return: Success:
+ * Return: Success:
*
- * Failure:
+ * Failure:
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, December 9, 1997
*
* Modifications:
@@ -229,34 +209,31 @@ test_compound (void)
*-------------------------------------------------------------------------
*/
int
-main (void)
+main(void)
{
- herr_t status;
- intn nerrors = 0;
-
- H5init ();
-
- status = test_classes ();
- nerrors += status<0 ? 1 : 0;
-
- status = test_copy ();
- nerrors += status<0 ? 1 : 0;
-
- status = test_compound ();
- nerrors += status<0 ? 1 : 0;
-
-
- if (nerrors) {
- printf ("***** %d DATA TYPE TEST%s FAILED! *****\n",
- nerrors, 1==nerrors?"":"S");
- if (isatty (1)) {
- printf ("(Redirect output to a pager or a file to see debug "
- "output)\n");
- }
- exit (1);
- }
-
- printf ("All data type tests passed.\n");
- exit (0);
+ herr_t status;
+ intn nerrors = 0;
+
+ H5init();
+
+ status = test_classes();
+ nerrors += status < 0 ? 1 : 0;
+
+ status = test_copy();
+ nerrors += status < 0 ? 1 : 0;
+
+ status = test_compound();
+ nerrors += status < 0 ? 1 : 0;
+
+ if (nerrors) {
+ printf("***** %d DATA TYPE TEST%s FAILED! *****\n",
+ nerrors, 1 == nerrors ? "" : "S");
+ if (isatty(1)) {
+ printf("(Redirect output to a pager or a file to see debug "
+ "output)\n");
+ }
+ exit(1);
+ }
+ printf("All data type tests passed.\n");
+ exit(0);
}
-
diff --git a/test/hyperslab.c b/test/hyperslab.c
index 64c731e..82f78c4 100644
--- a/test/hyperslab.c
+++ b/test/hyperslab.c
@@ -2,14 +2,14 @@
* Copyright (C) 1997 NCSA
* All rights reserved.
*
- * Programmer: Robb Matzke <matzke@llnl.gov>
- * Friday, October 10, 1997
+ * Programmer: Robb Matzke <matzke@llnl.gov>
+ * Friday, October 10, 1997
*
- * Purpose: Hyperslab operations are rather complex, so this file
- * attempts to test them extensively so we can be relatively
- * sure they really work. We only test 1d, 2d, and 3d cases
- * because testing general dimensionalities would require us to
- * rewrite much of the hyperslab stuff.
+ * Purpose: Hyperslab operations are rather complex, so this file
+ * attempts to test them extensively so we can be relatively
+ * sure they really work. We only test 1d, 2d, and 3d cases
+ * because testing general dimensionalities would require us to
+ * rewrite much of the hyperslab stuff.
*/
#include <H5private.h>
#include <H5MMprivate.h>
@@ -20,22 +20,21 @@
#endif
#define AT() printf (" at %s:%d in %s()\n",__FILE__,__LINE__,__FUNCTION__);
-#define TEST_SMALL 0x0001
-#define TEST_MEDIUM 0x0002
-
-#define VARIABLE_SRC 0
-#define VARIABLE_DST 1
-#define VARIABLE_BOTH 2
+#define TEST_SMALL 0x0001
+#define TEST_MEDIUM 0x0002
+#define VARIABLE_SRC 0
+#define VARIABLE_DST 1
+#define VARIABLE_BOTH 2
/*-------------------------------------------------------------------------
- * Function: init_full
+ * Function: init_full
*
- * Purpose: Initialize full array.
+ * Purpose: Initialize full array.
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, October 10, 1997
*
* Modifications:
@@ -43,33 +42,31 @@
*-------------------------------------------------------------------------
*/
static uintn
-init_full (uint8 *array, size_t nx, size_t ny, size_t nz)
+init_full(uint8 *array, size_t nx, size_t ny, size_t nz)
{
- int i, j, k;
- uint8 acc=128;
- uintn total=0;
-
- for (i=0; i<nx; i++) {
- for (j=0; j<ny; j++) {
- for (k=0; k<nz; k++) {
- total += acc;
- *array++ = acc++;
- }
- }
- }
- return total;
+ int i, j, k;
+ uint8 acc = 128;
+ uintn total = 0;
+
+ for (i = 0; i < nx; i++) {
+ for (j = 0; j < ny; j++) {
+ for (k = 0; k < nz; k++) {
+ total += acc;
+ *array++ = acc++;
+ }
+ }
+ }
+ return total;
}
-
-
/*-------------------------------------------------------------------------
- * Function: print_array
+ * Function: print_array
*
- * Purpose: Prints the values in an array
+ * Purpose: Prints the values in an array
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, October 10, 1997
*
* Modifications:
@@ -77,40 +74,40 @@ init_full (uint8 *array, size_t nx, size_t ny, size_t nz)
*-------------------------------------------------------------------------
*/
static void
-print_array (uint8 *array, size_t nx, size_t ny, size_t nz)
+print_array(uint8 *array, size_t nx, size_t ny, size_t nz)
{
- int i, j, k;
-
- for (i=0; i<nx; i++) {
- if (nz>1) {
- printf ("i=%d:\n", i);
- } else {
- printf ("%03d:", i);
- }
-
- for (j=0; j<ny; j++) {
- if (nz>1) printf ("%03d:", j);
- for (k=0; k<nz; k++) {
- printf (" %3d", *array++);
- }
- if (nz>1) printf ("\n");
- }
- printf ("\n");
- }
+ int i, j, k;
+
+ for (i = 0; i < nx; i++) {
+ if (nz > 1) {
+ printf("i=%d:\n", i);
+ } else {
+ printf("%03d:", i);
+ }
+
+ for (j = 0; j < ny; j++) {
+ if (nz > 1)
+ printf("%03d:", j);
+ for (k = 0; k < nz; k++) {
+ printf(" %3d", *array++);
+ }
+ if (nz > 1)
+ printf("\n");
+ }
+ printf("\n");
+ }
}
-
-
/*-------------------------------------------------------------------------
- * Function: print_ref
+ * Function: print_ref
*
- * Purpose: Prints the reference value
+ * Purpose: Prints the reference value
*
- * Return: Success: 0
+ * Return: Success: 0
*
- * Failure:
+ * Failure:
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, October 10, 1997
*
* Modifications:
@@ -118,28 +115,27 @@ print_array (uint8 *array, size_t nx, size_t ny, size_t nz)
*-------------------------------------------------------------------------
*/
static void
-print_ref (size_t nx, size_t ny, size_t nz)
+print_ref(size_t nx, size_t ny, size_t nz)
{
- uint8 *array;
+ uint8 *array;
- array = H5MM_xcalloc (nx*ny*nz, sizeof(uint8));
+ array = H5MM_xcalloc(nx * ny * nz, sizeof(uint8));
- printf ("Reference array:\n");
- init_full (array, nx, ny, nz);
- print_array (array, nx, ny, nz);
+ printf("Reference array:\n");
+ init_full(array, nx, ny, nz);
+ print_array(array, nx, ny, nz);
}
-
/*-------------------------------------------------------------------------
- * Function: test_fill
+ * Function: test_fill
*
- * Purpose: Tests the H5V_hyper_fill() function.
+ * Purpose: Tests the H5V_hyper_fill() function.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Saturday, October 11, 1997
*
* Modifications:
@@ -147,156 +143,153 @@ print_ref (size_t nx, size_t ny, size_t nz)
*-------------------------------------------------------------------------
*/
static herr_t
-test_fill (size_t nx, size_t ny, size_t nz,
- size_t di, size_t dj, size_t dk,
- size_t ddx, size_t ddy, size_t ddz)
+test_fill(size_t nx, size_t ny, size_t nz,
+ size_t di, size_t dj, size_t dk,
+ size_t ddx, size_t ddy, size_t ddz)
{
- uint8 *dst=NULL; /*destination array */
- size_t hs_size[3]; /*hyperslab size */
- size_t dst_size[3]; /*destination total size */
- size_t dst_offset[3]; /*offset of hyperslab in dest */
- uintn ref_value; /*reference value */
- uintn acc; /*accumulator */
- int i, j, k, dx, dy, dz, u, v, w; /*counters */
- int ndims; /*hyperslab dimensionality */
- char dim[64],s[256]; /*temp string */
- uintn fill_value; /*fill value */
-
- /*
- * Dimensionality.
- */
- if (0==nz) {
- if (0==ny) {
- ndims = 1;
- ny = nz = 1;
- sprintf (dim, "%lu", (unsigned long)nx);
- } else {
- ndims = 2;
- nz = 1;
- sprintf (dim, "%lux%lu", (unsigned long)nx, (unsigned long)ny);
- }
- } else {
- ndims = 3;
- sprintf (dim, "%lux%lux%lu",
- (unsigned long)nx, (unsigned long)ny, (unsigned long)nz);
- }
- sprintf (s, "Testing hyperslab fill %-11s variable hyperslab ", dim);
- printf ("%-70s", s);
- fflush (stdout);
-
- /* Allocate array */
- dst = H5MM_xcalloc (nx*ny*nz, 1);
- init_full (dst, nx, ny, nz);
-
-
- for (i=0; i<nx; i+=di) {
- for (j=0; j<ny; j+=dj) {
- for (k=0; k<nz; k+=dk) {
- for (dx=1; dx<=nx-i; dx+=ddx) {
- for (dy=1; dy<=ny-j; dy+=ddy) {
- for (dz=1; dz<=nz-k; dz+=ddz) {
-
- /* Describe the hyperslab */
- dst_size[0] = nx;
- dst_size[1] = ny;
- dst_size[2] = nz;
- dst_offset[0] = i;
- dst_offset[1] = j;
- dst_offset[2] = k;
- hs_size[0] = dx;
- hs_size[1] = dy;
- hs_size[2] = dz;
-
- for (fill_value=0; fill_value<256; fill_value+=64) {
- /*
- * Initialize the full array, then subtract the
- * original * fill values and add the new ones.
- */
- ref_value = init_full (dst, nx, ny, nz);
- for (u=dst_offset[0]; u<dst_offset[0]+dx; u++) {
- for (v=dst_offset[1]; v<dst_offset[1]+dy; v++) {
- for (w=dst_offset[2]; w<dst_offset[2]+dz; w++) {
- ref_value -= dst[u*ny*nz + v*nz + w];
- }
- }
- }
- ref_value += fill_value * dx * dy * dz;
-
- /* Fill the hyperslab with some value */
- H5V_hyper_fill (ndims, hs_size, dst_size, dst_offset,
- dst, fill_value);
-
- /*
- * Sum the array and compare it to the reference
- * value.
- */
- acc = 0;
- for (u=0; u<nx; u++) {
- for (v=0; v<ny; v++) {
- for (w=0; w<nz; w++) {
- acc += dst[u*ny*nz + v*nz + w];
- }
- }
- }
-
- if (acc != ref_value) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- /*
- * Print debugging info unless output is going
- * directly to a terminal.
- */
- AT ();
- printf (" acc != ref_value\n");
- printf (" i=%d, j=%d, k=%d, "
- "dx=%d, dy=%d, dz=%d, fill=%d\n",
- i, j, k, dx, dy, dz, fill_value);
- print_ref (nx, ny, nz);
- printf ("\n Result is:\n");
- print_array (dst, nx, ny, nz);
- }
- goto error;
- }
- }
- }
- }
- }
- }
- }
- }
- puts (" PASSED");
- H5MM_xfree (dst);
- return SUCCEED;
-
- error:
- H5MM_xfree (dst);
- return FAIL;
+ uint8 *dst = NULL; /*destination array */
+ size_t hs_size[3]; /*hyperslab size */
+ size_t dst_size[3]; /*destination total size */
+ size_t dst_offset[3]; /*offset of hyperslab in dest */
+ uintn ref_value; /*reference value */
+ uintn acc; /*accumulator */
+ int i, j, k, dx, dy, dz, u, v, w; /*counters */
+ int ndims; /*hyperslab dimensionality */
+ char dim[64], s[256]; /*temp string */
+ uintn fill_value; /*fill value */
+
+ /*
+ * Dimensionality.
+ */
+ if (0 == nz) {
+ if (0 == ny) {
+ ndims = 1;
+ ny = nz = 1;
+ sprintf(dim, "%lu", (unsigned long) nx);
+ } else {
+ ndims = 2;
+ nz = 1;
+ sprintf(dim, "%lux%lu", (unsigned long) nx, (unsigned long) ny);
+ }
+ } else {
+ ndims = 3;
+ sprintf(dim, "%lux%lux%lu",
+ (unsigned long) nx, (unsigned long) ny, (unsigned long) nz);
+ }
+ sprintf(s, "Testing hyperslab fill %-11s variable hyperslab ", dim);
+ printf("%-70s", s);
+ fflush(stdout);
+
+ /* Allocate array */
+ dst = H5MM_xcalloc(nx * ny * nz, 1);
+ init_full(dst, nx, ny, nz);
+
+ for (i = 0; i < nx; i += di) {
+ for (j = 0; j < ny; j += dj) {
+ for (k = 0; k < nz; k += dk) {
+ for (dx = 1; dx <= nx - i; dx += ddx) {
+ for (dy = 1; dy <= ny - j; dy += ddy) {
+ for (dz = 1; dz <= nz - k; dz += ddz) {
+
+ /* Describe the hyperslab */
+ dst_size[0] = nx;
+ dst_size[1] = ny;
+ dst_size[2] = nz;
+ dst_offset[0] = i;
+ dst_offset[1] = j;
+ dst_offset[2] = k;
+ hs_size[0] = dx;
+ hs_size[1] = dy;
+ hs_size[2] = dz;
+
+ for (fill_value = 0; fill_value < 256; fill_value += 64) {
+ /*
+ * Initialize the full array, then subtract the
+ * original * fill values and add the new ones.
+ */
+ ref_value = init_full(dst, nx, ny, nz);
+ for (u = dst_offset[0]; u < dst_offset[0] + dx; u++) {
+ for (v = dst_offset[1]; v < dst_offset[1] + dy; v++) {
+ for (w = dst_offset[2]; w < dst_offset[2] + dz; w++) {
+ ref_value -= dst[u * ny * nz + v * nz + w];
+ }
+ }
+ }
+ ref_value += fill_value * dx * dy * dz;
+
+ /* Fill the hyperslab with some value */
+ H5V_hyper_fill(ndims, hs_size, dst_size, dst_offset,
+ dst, fill_value);
+
+ /*
+ * Sum the array and compare it to the reference
+ * value.
+ */
+ acc = 0;
+ for (u = 0; u < nx; u++) {
+ for (v = 0; v < ny; v++) {
+ for (w = 0; w < nz; w++) {
+ acc += dst[u * ny * nz + v * nz + w];
+ }
+ }
+ }
+
+ if (acc != ref_value) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ /*
+ * Print debugging info unless output is going
+ * directly to a terminal.
+ */
+ AT();
+ printf(" acc != ref_value\n");
+ printf(" i=%d, j=%d, k=%d, "
+ "dx=%d, dy=%d, dz=%d, fill=%d\n",
+ i, j, k, dx, dy, dz, fill_value);
+ print_ref(nx, ny, nz);
+ printf("\n Result is:\n");
+ print_array(dst, nx, ny, nz);
+ }
+ goto error;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ puts(" PASSED");
+ H5MM_xfree(dst);
+ return SUCCEED;
+
+ error:
+ H5MM_xfree(dst);
+ return FAIL;
}
-
-
/*-------------------------------------------------------------------------
- * Function: test_copy
+ * Function: test_copy
*
- * Purpose: Tests H5V_hyper_copy().
+ * Purpose: Tests H5V_hyper_copy().
*
- * The NX, NY, and NZ arguments are the size for the source and
- * destination arrays. You map pass zero for NZ or for NY and
- * NZ to test the 2-d and 1-d cases respectively.
+ * The NX, NY, and NZ arguments are the size for the source and
+ * destination arrays. You map pass zero for NZ or for NY and
+ * NZ to test the 2-d and 1-d cases respectively.
*
- * A hyperslab is copied from/to (depending on MODE) various
- * places in SRC and DST beginning at 0,0,0 and increasing
- * location by DI,DJ,DK in the x, y, and z directions.
+ * A hyperslab is copied from/to (depending on MODE) various
+ * places in SRC and DST beginning at 0,0,0 and increasing
+ * location by DI,DJ,DK in the x, y, and z directions.
*
- * For each hyperslab location, various sizes of hyperslabs are
- * tried beginning with 1x1x1 and increasing the size in each
- * dimension by DDX,DDY,DDZ.
+ * For each hyperslab location, various sizes of hyperslabs are
+ * tried beginning with 1x1x1 and increasing the size in each
+ * dimension by DDX,DDY,DDZ.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, October 10, 1997
*
* Modifications:
@@ -304,257 +297,254 @@ test_fill (size_t nx, size_t ny, size_t nz,
*-------------------------------------------------------------------------
*/
static herr_t
-test_copy (int mode,
- size_t nx, size_t ny, size_t nz,
- size_t di, size_t dj, size_t dk,
- size_t ddx, size_t ddy, size_t ddz)
+test_copy(int mode,
+ size_t nx, size_t ny, size_t nz,
+ size_t di, size_t dj, size_t dk,
+ size_t ddx, size_t ddy, size_t ddz)
{
- uint8 *src=NULL; /*source array */
- uint8 *dst=NULL; /*destination array */
- size_t hs_size[3]; /*hyperslab size */
- size_t dst_size[3]; /*destination total size */
- size_t src_size[3]; /*source total size */
- size_t dst_offset[3]; /*offset of hyperslab in dest */
- size_t src_offset[3]; /*offset of hyperslab in source */
- uintn ref_value; /*reference value */
- uintn acc; /*accumulator */
- int i, j, k, dx, dy, dz, u, v, w; /*counters */
- int ndims; /*hyperslab dimensionality */
- char dim[64], s[256]; /*temp string */
- const char *sub;
-
- /*
- * Dimensionality.
- */
- if (0==nz) {
- if (0==ny) {
- ndims = 1;
- ny = nz = 1;
- sprintf (dim, "%lu", (unsigned long)nx);
- } else {
- ndims = 2;
- nz = 1;
- sprintf (dim, "%lux%lu", (unsigned long)nx, (unsigned long)ny);
- }
- } else {
- ndims = 3;
- sprintf (dim, "%lux%lux%lu",
- (unsigned long)nx, (unsigned long)ny, (unsigned long)nz);
- }
-
- switch (mode) {
- case VARIABLE_SRC:
- /*
- * The hyperslab "travels" through the source array but the
- * destination hyperslab is always at the origin of the destination
- * array.
- */
- sub = "variable source";
- break;
- case VARIABLE_DST:
- /*
- * We always read a hyperslab from the origin of the source and copy it
- * to a hyperslab at various locations in the destination.
- */
- sub = "variable destination";
- break;
- case VARIABLE_BOTH:
- /*
- * We read the hyperslab from various locations in the source and copy
- * it to the same location in the destination.
- */
- sub = "sync source & dest ";
- break;
- default:
- abort ();
- }
-
- sprintf (s, "Testing hyperslab copy %-11s %s", dim, sub);
- printf ("%-70s", s);
- fflush (stdout);
-
- /*
- * Allocate arrays
- */
- src = H5MM_xcalloc (nx*ny*nz, 1);
- dst = H5MM_xcalloc (nx*ny*nz, 1);
- init_full (src, nx, ny, nz);
-
- for (i=0; i<nx; i+=di) {
- for (j=0; j<ny; j+=dj) {
- for (k=0; k<nz; k+=dk) {
- for (dx=1; dx<=nx-i; dx+=ddx) {
- for (dy=1; dy<=ny-j; dy+=ddy) {
- for (dz=1; dz<=nz-k; dz+=ddz) {
-
- /*
- * Describe the source and destination hyperslabs and the
- * arrays to which they belong.
- */
- hs_size[0] = dx;
- hs_size[1] = dy;
- hs_size[2] = dz;
- dst_size[0] = src_size[0] = nx;
- dst_size[1] = src_size[1] = ny;
- dst_size[2] = src_size[2] = nz;
- switch (mode) {
- case VARIABLE_SRC:
- dst_offset[0] = 0;
- dst_offset[1] = 0;
- dst_offset[2] = 0;
- src_offset[0] = i;
- src_offset[1] = j;
- src_offset[2] = k;
- break;
- case VARIABLE_DST:
- dst_offset[0] = i;
- dst_offset[1] = j;
- dst_offset[2] = k;
- src_offset[0] = 0;
- src_offset[1] = 0;
- src_offset[2] = 0;
- break;
- case VARIABLE_BOTH:
- dst_offset[0] = i;
- dst_offset[1] = j;
- dst_offset[2] = k;
- src_offset[0] = i;
- src_offset[1] = j;
- src_offset[2] = k;
- break;
- default:
- abort ();
- }
-
- /*
- * Sum the main array directly to get a reference value
- * to compare against later.
- */
- ref_value = 0;
- for (u=src_offset[0]; u<src_offset[0]+dx; u++) {
- for (v=src_offset[1]; v<src_offset[1]+dy; v++) {
- for (w=src_offset[2]; w<src_offset[2]+dz; w++) {
- ref_value += src[u*ny*nz + v*nz + w];
- }
- }
- }
-
- /*
- * Set all loc values to 1 so we can detect writing
- * outside the hyperslab.
- */
- for (u=0; u<nx; u++) {
- for (v=0; v<ny; v++) {
- for (w=0; w<nz; w++) {
- dst[u*ny*nz + v*nz + w] = 1;
- }
- }
- }
-
- /*
- * Copy a hyperslab from the global array to the local
- * array.
- */
- H5V_hyper_copy (ndims, hs_size,
- dst_size, dst_offset, dst,
- src_size, src_offset, src);
-
- /*
- * Sum the destination hyperslab. It should be the same
- * as the reference value.
- */
- acc = 0;
- for (u=dst_offset[0]; u<dst_offset[0]+dx; u++) {
- for (v=dst_offset[1]; v<dst_offset[1]+dy; v++) {
- for (w=dst_offset[2]; w<dst_offset[2]+dz; w++) {
- acc += dst[u*ny*nz + v*nz + w];
- }
- }
- }
- if (acc != ref_value) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- /*
- * Print debugging info unless output is going
- * directly to a terminal.
- */
- AT ();
- printf (" acc != ref_value\n");
- printf (" i=%d, j=%d, k=%d, "
- "dx=%d, dy=%d, dz=%d\n",
- i, j, k, dx, dy, dz);
- print_ref (nx, ny, nz);
- printf ("\n Destination array is:\n");
- print_array (dst, nx, ny, nz);
- }
- goto error;
- }
-
- /*
- * Sum the entire array. It should be a fixed amount
- * larger than the reference value since we added the
- * border of 1's to the hyperslab.
- */
- acc = 0;
- for (u=0; u<nx; u++) {
- for (v=0; v<ny; v++) {
- for (w=0; w<nz; w++) {
- acc += dst[u*ny*nz + v*nz + w];
- }
- }
- }
- if (acc != ref_value + nx*ny*nz - dx*dy*dz) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- /*
- * Print debugging info unless output is going
- * directly to a terminal.
- */
- AT ();
- printf (" acc != ref_value + nx*ny*nz - "
- "dx*dy*dz\n");
- printf (" i=%d, j=%d, k=%d, "
- "dx=%d, dy=%d, dz=%d\n",
- i, j, k, dx, dy, dz);
- print_ref (nx, ny, nz);
- printf ("\n Destination array is:\n");
- print_array (dst, nx, ny, nz);
- }
- goto error;
- }
- }
- }
- }
- }
- }
- }
- puts (" PASSED");
- H5MM_xfree (src);
- H5MM_xfree (dst);
- return SUCCEED;
-
- error:
- H5MM_xfree (src);
- H5MM_xfree (dst);
- return FAIL;
+ uint8 *src = NULL; /*source array */
+ uint8 *dst = NULL; /*destination array */
+ size_t hs_size[3]; /*hyperslab size */
+ size_t dst_size[3]; /*destination total size */
+ size_t src_size[3]; /*source total size */
+ size_t dst_offset[3]; /*offset of hyperslab in dest */
+ size_t src_offset[3]; /*offset of hyperslab in source */
+ uintn ref_value; /*reference value */
+ uintn acc; /*accumulator */
+ int i, j, k, dx, dy, dz, u, v, w; /*counters */
+ int ndims; /*hyperslab dimensionality */
+ char dim[64], s[256]; /*temp string */
+ const char *sub;
+
+ /*
+ * Dimensionality.
+ */
+ if (0 == nz) {
+ if (0 == ny) {
+ ndims = 1;
+ ny = nz = 1;
+ sprintf(dim, "%lu", (unsigned long) nx);
+ } else {
+ ndims = 2;
+ nz = 1;
+ sprintf(dim, "%lux%lu", (unsigned long) nx, (unsigned long) ny);
+ }
+ } else {
+ ndims = 3;
+ sprintf(dim, "%lux%lux%lu",
+ (unsigned long) nx, (unsigned long) ny, (unsigned long) nz);
+ }
+
+ switch (mode) {
+ case VARIABLE_SRC:
+ /*
+ * The hyperslab "travels" through the source array but the
+ * destination hyperslab is always at the origin of the destination
+ * array.
+ */
+ sub = "variable source";
+ break;
+ case VARIABLE_DST:
+ /*
+ * We always read a hyperslab from the origin of the source and copy it
+ * to a hyperslab at various locations in the destination.
+ */
+ sub = "variable destination";
+ break;
+ case VARIABLE_BOTH:
+ /*
+ * We read the hyperslab from various locations in the source and copy
+ * it to the same location in the destination.
+ */
+ sub = "sync source & dest ";
+ break;
+ default:
+ abort();
+ }
+
+ sprintf(s, "Testing hyperslab copy %-11s %s", dim, sub);
+ printf("%-70s", s);
+ fflush(stdout);
+
+ /*
+ * Allocate arrays
+ */
+ src = H5MM_xcalloc(nx * ny * nz, 1);
+ dst = H5MM_xcalloc(nx * ny * nz, 1);
+ init_full(src, nx, ny, nz);
+
+ for (i = 0; i < nx; i += di) {
+ for (j = 0; j < ny; j += dj) {
+ for (k = 0; k < nz; k += dk) {
+ for (dx = 1; dx <= nx - i; dx += ddx) {
+ for (dy = 1; dy <= ny - j; dy += ddy) {
+ for (dz = 1; dz <= nz - k; dz += ddz) {
+
+ /*
+ * Describe the source and destination hyperslabs and the
+ * arrays to which they belong.
+ */
+ hs_size[0] = dx;
+ hs_size[1] = dy;
+ hs_size[2] = dz;
+ dst_size[0] = src_size[0] = nx;
+ dst_size[1] = src_size[1] = ny;
+ dst_size[2] = src_size[2] = nz;
+ switch (mode) {
+ case VARIABLE_SRC:
+ dst_offset[0] = 0;
+ dst_offset[1] = 0;
+ dst_offset[2] = 0;
+ src_offset[0] = i;
+ src_offset[1] = j;
+ src_offset[2] = k;
+ break;
+ case VARIABLE_DST:
+ dst_offset[0] = i;
+ dst_offset[1] = j;
+ dst_offset[2] = k;
+ src_offset[0] = 0;
+ src_offset[1] = 0;
+ src_offset[2] = 0;
+ break;
+ case VARIABLE_BOTH:
+ dst_offset[0] = i;
+ dst_offset[1] = j;
+ dst_offset[2] = k;
+ src_offset[0] = i;
+ src_offset[1] = j;
+ src_offset[2] = k;
+ break;
+ default:
+ abort();
+ }
+
+ /*
+ * Sum the main array directly to get a reference value
+ * to compare against later.
+ */
+ ref_value = 0;
+ for (u = src_offset[0]; u < src_offset[0] + dx; u++) {
+ for (v = src_offset[1]; v < src_offset[1] + dy; v++) {
+ for (w = src_offset[2]; w < src_offset[2] + dz; w++) {
+ ref_value += src[u * ny * nz + v * nz + w];
+ }
+ }
+ }
+
+ /*
+ * Set all loc values to 1 so we can detect writing
+ * outside the hyperslab.
+ */
+ for (u = 0; u < nx; u++) {
+ for (v = 0; v < ny; v++) {
+ for (w = 0; w < nz; w++) {
+ dst[u * ny * nz + v * nz + w] = 1;
+ }
+ }
+ }
+
+ /*
+ * Copy a hyperslab from the global array to the local
+ * array.
+ */
+ H5V_hyper_copy(ndims, hs_size,
+ dst_size, dst_offset, dst,
+ src_size, src_offset, src);
+
+ /*
+ * Sum the destination hyperslab. It should be the same
+ * as the reference value.
+ */
+ acc = 0;
+ for (u = dst_offset[0]; u < dst_offset[0] + dx; u++) {
+ for (v = dst_offset[1]; v < dst_offset[1] + dy; v++) {
+ for (w = dst_offset[2]; w < dst_offset[2] + dz; w++) {
+ acc += dst[u * ny * nz + v * nz + w];
+ }
+ }
+ }
+ if (acc != ref_value) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ /*
+ * Print debugging info unless output is going
+ * directly to a terminal.
+ */
+ AT();
+ printf(" acc != ref_value\n");
+ printf(" i=%d, j=%d, k=%d, "
+ "dx=%d, dy=%d, dz=%d\n",
+ i, j, k, dx, dy, dz);
+ print_ref(nx, ny, nz);
+ printf("\n Destination array is:\n");
+ print_array(dst, nx, ny, nz);
+ }
+ goto error;
+ }
+ /*
+ * Sum the entire array. It should be a fixed amount
+ * larger than the reference value since we added the
+ * border of 1's to the hyperslab.
+ */
+ acc = 0;
+ for (u = 0; u < nx; u++) {
+ for (v = 0; v < ny; v++) {
+ for (w = 0; w < nz; w++) {
+ acc += dst[u * ny * nz + v * nz + w];
+ }
+ }
+ }
+ if (acc != ref_value + nx * ny * nz - dx * dy * dz) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ /*
+ * Print debugging info unless output is going
+ * directly to a terminal.
+ */
+ AT();
+ printf(" acc != ref_value + nx*ny*nz - "
+ "dx*dy*dz\n");
+ printf(" i=%d, j=%d, k=%d, "
+ "dx=%d, dy=%d, dz=%d\n",
+ i, j, k, dx, dy, dz);
+ print_ref(nx, ny, nz);
+ printf("\n Destination array is:\n");
+ print_array(dst, nx, ny, nz);
+ }
+ goto error;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ puts(" PASSED");
+ H5MM_xfree(src);
+ H5MM_xfree(dst);
+ return SUCCEED;
+
+ error:
+ H5MM_xfree(src);
+ H5MM_xfree(dst);
+ return FAIL;
}
-
-
/*-------------------------------------------------------------------------
- * Function: test_multifill
+ * Function: test_multifill
*
- * Purpose: Tests the H5V_stride_copy() function by using it to fill a
- * hyperslab by replicating a multi-byte sequence. This might
- * be useful to initialize an array of structs with a default
- * struct value, or to initialize an array of floating-point
- * values with a default bit-pattern.
+ * Purpose: Tests the H5V_stride_copy() function by using it to fill a
+ * hyperslab by replicating a multi-byte sequence. This might
+ * be useful to initialize an array of structs with a default
+ * struct value, or to initialize an array of floating-point
+ * values with a default bit-pattern.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Saturday, October 11, 1997
*
* Modifications:
@@ -562,112 +552,111 @@ test_copy (int mode,
*-------------------------------------------------------------------------
*/
static herr_t
-test_multifill (int nx)
+test_multifill(int nx)
{
- int i, j;
- size_t size;
- intn src_stride;
- intn dst_stride;
- char s[64];
-
- struct a_struct {
- int left;
- double mid;
- int right;
- } fill, *src=NULL, *dst=NULL;
-
- printf ("%-70s", "Testing multi-byte fill value");
- fflush (stdout);
-
- /* Initialize the source and destination */
- src = H5MM_xmalloc (nx * sizeof(*src));
- dst = H5MM_xmalloc (nx * sizeof(*dst));
- for (i=0; i<nx; i++) {
- src[i].left = 1111111;
- src[i].mid = 12345.6789;
- src[i].right = 2222222;
- dst[i].left = 3333333;
- dst[i].mid = 98765.4321;
- dst[i].right = 4444444;
- }
-
- /*
- * Describe the fill value. The zero stride says to read the same thing
- * over and over again.
- */
- fill.left = 55555555;
- fill.mid = 3.1415927;
- fill.right = 66666666;
- src_stride = 0;
-
- /*
- * The destination stride says to fill in one value per array element
- */
- dst_stride = sizeof(fill);
-
- /*
- * Copy the fill value into each element
- */
- size = nx;
- H5V_stride_copy (1, sizeof(double), &size,
- &dst_stride, &(dst[0].mid), &src_stride, &(fill.mid));
-
- /*
- * Check
- */
- s[0] = '\0';
- for (i=0; i<nx; i++) {
- if (dst[i].left != 3333333) {
- sprintf (s, "bad dst[%d].left", i);
- } else if (dst[i].mid != fill.mid) {
- sprintf (s, "bad dst[%d].mid", i);
- } else if (dst[i].right != 4444444) {
- sprintf (s, "bad dst[%d].right", i);
- }
- if (s[0]) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" fill={%d,%g,%d}\n ",
- fill.left, fill.mid, fill.right);
- for (j=0; j<sizeof(fill); j++) {
- printf (" %02x", ((uint8*)&fill)[j]);
- }
- printf ("\n dst[%d]={%d,%g,%d}\n ",
- i, dst[i].left, dst[i].mid, dst[i].right);
- for (j=0; j<sizeof(dst[i]); j++) {
- printf (" %02x", ((uint8*)(dst+i))[j]);
- }
- printf ("\n");
- }
- goto error;
- }
- }
-
- puts (" PASSED");
- H5MM_xfree (src);
- H5MM_xfree (dst);
- return SUCCEED;
-
- error:
- H5MM_xfree (src);
- H5MM_xfree (dst);
- return FAIL;
+ int i, j;
+ size_t size;
+ intn src_stride;
+ intn dst_stride;
+ char s[64];
+
+ struct a_struct {
+ int left;
+ double mid;
+ int right;
+ } fill , *src = NULL, *dst = NULL;
+
+ printf("%-70s", "Testing multi-byte fill value");
+ fflush(stdout);
+
+ /* Initialize the source and destination */
+ src = H5MM_xmalloc(nx * sizeof(*src));
+ dst = H5MM_xmalloc(nx * sizeof(*dst));
+ for (i = 0; i < nx; i++) {
+ src[i].left = 1111111;
+ src[i].mid = 12345.6789;
+ src[i].right = 2222222;
+ dst[i].left = 3333333;
+ dst[i].mid = 98765.4321;
+ dst[i].right = 4444444;
+ }
+
+ /*
+ * Describe the fill value. The zero stride says to read the same thing
+ * over and over again.
+ */
+ fill.left = 55555555;
+ fill.mid = 3.1415927;
+ fill.right = 66666666;
+ src_stride = 0;
+
+ /*
+ * The destination stride says to fill in one value per array element
+ */
+ dst_stride = sizeof(fill);
+
+ /*
+ * Copy the fill value into each element
+ */
+ size = nx;
+ H5V_stride_copy(1, sizeof(double), &size,
+ &dst_stride, & (dst[0].mid), &src_stride, &(fill.mid));
+
+ /*
+ * Check
+ */
+ s[0] = '\0';
+ for (i = 0; i < nx; i++) {
+ if (dst[i].left != 3333333) {
+ sprintf(s, "bad dst[%d].left", i);
+ } else if (dst[i].mid != fill.mid) {
+ sprintf(s, "bad dst[%d].mid", i);
+ } else if (dst[i].right != 4444444) {
+ sprintf(s, "bad dst[%d].right", i);
+ }
+ if (s[0]) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" fill={%d,%g,%d}\n ",
+ fill.left, fill.mid, fill.right);
+ for (j = 0; j < sizeof(fill); j++) {
+ printf(" %02x", ((uint8 *) &fill)[j]);
+ }
+ printf("\n dst[%d]={%d,%g,%d}\n ",
+ i, dst[i].left, dst[i].mid, dst[i].right);
+ for (j = 0; j < sizeof(dst[i]); j++) {
+ printf(" %02x", ((uint8 *) (dst + i))[j]);
+ }
+ printf("\n");
+ }
+ goto error;
+ }
+ }
+
+ puts(" PASSED");
+ H5MM_xfree(src);
+ H5MM_xfree(dst);
+ return SUCCEED;
+
+ error:
+ H5MM_xfree(src);
+ H5MM_xfree(dst);
+ return FAIL;
}
-
/*-------------------------------------------------------------------------
- * Function: test_endian
+ * Function: test_endian
*
- * Purpose: Tests the H5V_stride_copy() function by using it to copy an
- * array of integers and swap the byte ordering from little
- * endian to big endian or vice versa depending on the hardware.
+ * Purpose: Tests the H5V_stride_copy() function by using it to copy an
+ * array of integers and swap the byte ordering from little
+ * endian to big endian or vice versa depending on the hardware.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Saturday, October 11, 1997
*
* Modifications:
@@ -675,80 +664,78 @@ test_multifill (int nx)
*-------------------------------------------------------------------------
*/
static herr_t
-test_endian (size_t nx)
+test_endian(size_t nx)
{
- uint8 *src=NULL; /*source array */
- uint8 *dst=NULL; /*destination array */
- intn src_stride[2]; /*source strides */
- intn dst_stride[2]; /*destination strides */
- size_t size[2]; /*size vector */
- int i, j;
-
- printf ("%-70s", "Testing endian conversion by stride");
- fflush (stdout);
-
- /* Initialize arrays */
- src = H5MM_xmalloc (nx*4);
- init_full (src, nx, 4, 1);
- dst = H5MM_xcalloc (nx, 4);
-
- /* Initialize strides */
- src_stride[0] = 0;
- src_stride[1] = 1;
- dst_stride[0] = 8;
- dst_stride[1] = -1;
- size[0] = nx;
- size[1] = 4;
-
- /* Copy the array */
- H5V_stride_copy (2, 1, size, dst_stride, dst+3, src_stride, src);
-
- /* Compare */
- for (i=0; i<nx; i++) {
- for (j=0; j<4; j++) {
- if (src[i*4+j] != dst[i*4+3-j]) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- /*
- * Print debugging info unless output is going directly to a
- * terminal.
- */
- AT ();
- printf (" i=%d, j=%d\n", i, j);
- printf (" Source array is:\n");
- print_array (src, nx, 4, 1);
- printf ("\n Result is:\n");
- print_array (dst, nx, 4, 1);
- }
- goto error;
- }
- }
- }
-
- puts (" PASSED");
- H5MM_xfree (src);
- H5MM_xfree (dst);
- return SUCCEED;
-
- error:
- H5MM_xfree (src);
- H5MM_xfree (dst);
- return FAIL;
+ uint8 *src = NULL; /*source array */
+ uint8 *dst = NULL; /*destination array */
+ intn src_stride[2]; /*source strides */
+ intn dst_stride[2]; /*destination strides */
+ size_t size[2]; /*size vector */
+ int i, j;
+
+ printf("%-70s", "Testing endian conversion by stride");
+ fflush(stdout);
+
+ /* Initialize arrays */
+ src = H5MM_xmalloc(nx * 4);
+ init_full(src, nx, 4, 1);
+ dst = H5MM_xcalloc(nx, 4);
+
+ /* Initialize strides */
+ src_stride[0] = 0;
+ src_stride[1] = 1;
+ dst_stride[0] = 8;
+ dst_stride[1] = -1;
+ size[0] = nx;
+ size[1] = 4;
+
+ /* Copy the array */
+ H5V_stride_copy(2, 1, size, dst_stride, dst + 3, src_stride, src);
+
+ /* Compare */
+ for (i = 0; i < nx; i++) {
+ for (j = 0; j < 4; j++) {
+ if (src[i * 4 + j] != dst[i * 4 + 3 - j]) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ /*
+ * Print debugging info unless output is going directly to a
+ * terminal.
+ */
+ AT();
+ printf(" i=%d, j=%d\n", i, j);
+ printf(" Source array is:\n");
+ print_array(src, nx, 4, 1);
+ printf("\n Result is:\n");
+ print_array(dst, nx, 4, 1);
+ }
+ goto error;
+ }
+ }
+ }
+
+ puts(" PASSED");
+ H5MM_xfree(src);
+ H5MM_xfree(dst);
+ return SUCCEED;
+
+ error:
+ H5MM_xfree(src);
+ H5MM_xfree(dst);
+ return FAIL;
}
-
-
/*-------------------------------------------------------------------------
- * Function: test_transpose
+ * Function: test_transpose
*
- * Purpose: Copy a 2d array from here to there and transpose the elements
- * as it's copied.
+ * Purpose: Copy a 2d array from here to there and transpose the elements
+ * as it's copied.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Saturday, October 11, 1997
*
* Modifications:
@@ -756,105 +743,102 @@ test_endian (size_t nx)
*-------------------------------------------------------------------------
*/
static herr_t
-test_transpose (size_t nx, size_t ny)
+test_transpose(size_t nx, size_t ny)
{
- intn *src = NULL;
- intn *dst = NULL;
- int i, j;
- intn src_stride[2], dst_stride[2];
- size_t size[2];
- char s[256];
-
- sprintf (s, "Testing 2d transpose by stride %4lux%-lud",
- (unsigned long)nx, (unsigned long)ny);
- printf ("%-70s", s);
- fflush (stdout);
-
- /* Initialize */
- src = H5MM_xmalloc (nx*ny * sizeof(*src));
- for (i=0; i<nx; i++) {
- for (j=0; j<ny; j++) {
- src[i*ny + j] = i*ny + j;
- }
- }
- dst = H5MM_xcalloc (nx*ny, sizeof(*dst));
-
- /* Build stride info */
- size[0] = nx;
- size[1] = ny;
- src_stride[0] = 0;
- src_stride[1] = sizeof(*src);
- dst_stride[0] = (1 - nx*ny) * sizeof(*src);
- dst_stride[1] = nx * sizeof(*src);
-
- /* Copy and transpose */
- if (nx==ny) {
- H5V_stride_copy (2, sizeof(*src), size,
- dst_stride, dst,
- src_stride, src);
- } else {
- H5V_stride_copy (2, sizeof(*src), size,
- dst_stride, dst,
- src_stride, src);
- }
-
-
- /* Check */
- for (i=0; i<nx; i++) {
- for (j=0; j<ny; j++) {
- if (src[i*ny + j] != dst[j*nx + i]) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" diff at i=%d, j=%d\n", i, j);
- printf (" Source is:\n");
- for (i=0; i<nx; i++) {
- printf ("%3d:", i);
- for (j=0; j<ny; j++) {
- printf (" %6d", src[i*ny+j]);
- }
- printf ("\n");
- }
- printf ("\n Destination is:\n");
- for (i=0; i<ny; i++) {
- printf ("%3d:", i);
- for (j=0; j<nx; j++) {
- printf (" %6d", dst[i*nx+j]);
- }
- printf ("\n");
- }
- }
- goto error;
- }
- }
- }
-
- puts (" PASSED");
- H5MM_xfree (src);
- H5MM_xfree (dst);
- return SUCCEED;
-
- error:
- H5MM_xfree (src);
- H5MM_xfree (dst);
- return FAIL;
+ intn *src = NULL;
+ intn *dst = NULL;
+ int i, j;
+ intn src_stride[2], dst_stride[2];
+ size_t size[2];
+ char s[256];
+
+ sprintf(s, "Testing 2d transpose by stride %4lux%-lud",
+ (unsigned long) nx, (unsigned long) ny);
+ printf("%-70s", s);
+ fflush(stdout);
+
+ /* Initialize */
+ src = H5MM_xmalloc(nx * ny * sizeof(*src));
+ for (i = 0; i < nx; i++) {
+ for (j = 0; j < ny; j++) {
+ src[i * ny + j] = i * ny + j;
+ }
+ }
+ dst = H5MM_xcalloc(nx * ny, sizeof(*dst));
+
+ /* Build stride info */
+ size[0] = nx;
+ size[1] = ny;
+ src_stride[0] = 0;
+ src_stride[1] = sizeof(*src);
+ dst_stride[0] = (1 - nx * ny) * sizeof(*src);
+ dst_stride[1] = nx * sizeof(*src);
+
+ /* Copy and transpose */
+ if (nx == ny) {
+ H5V_stride_copy(2, sizeof(*src), size,
+ dst_stride, dst,
+ src_stride, src);
+ } else {
+ H5V_stride_copy(2, sizeof(*src), size,
+ dst_stride, dst,
+ src_stride, src);
+ }
+
+ /* Check */
+ for (i = 0; i < nx; i++) {
+ for (j = 0; j < ny; j++) {
+ if (src[i * ny + j] != dst[j * nx + i]) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" diff at i=%d, j=%d\n", i, j);
+ printf(" Source is:\n");
+ for (i = 0; i < nx; i++) {
+ printf("%3d:", i);
+ for (j = 0; j < ny; j++) {
+ printf(" %6d", src[i * ny + j]);
+ }
+ printf("\n");
+ }
+ printf("\n Destination is:\n");
+ for (i = 0; i < ny; i++) {
+ printf("%3d:", i);
+ for (j = 0; j < nx; j++) {
+ printf(" %6d", dst[i * nx + j]);
+ }
+ printf("\n");
+ }
+ }
+ goto error;
+ }
+ }
+ }
+
+ puts(" PASSED");
+ H5MM_xfree(src);
+ H5MM_xfree(dst);
+ return SUCCEED;
+
+ error:
+ H5MM_xfree(src);
+ H5MM_xfree(dst);
+ return FAIL;
}
-
-
/*-------------------------------------------------------------------------
- * Function: test_sub_super
+ * Function: test_sub_super
*
- * Purpose: Tests H5V_stride_copy() to reduce the resolution of an image
- * by copying half the pixels in the X and Y directions. Then
- * we use the small image and duplicate every pixel to result in
- * a 2x2 square.
+ * Purpose: Tests H5V_stride_copy() to reduce the resolution of an image
+ * by copying half the pixels in the X and Y directions. Then
+ * we use the small image and duplicate every pixel to result in
+ * a 2x2 square.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, October 13, 1997
*
* Modifications:
@@ -862,143 +846,140 @@ test_transpose (size_t nx, size_t ny)
*-------------------------------------------------------------------------
*/
static herr_t
-test_sub_super (size_t nx, size_t ny)
+test_sub_super(size_t nx, size_t ny)
{
- uint8 *full = NULL; /*original image */
- uint8 *half = NULL; /*image at 1/2 resolution */
- uint8 *twice = NULL; /*2x2 pixels */
- intn src_stride[4]; /*source stride info */
- intn dst_stride[4]; /*destination stride info */
- size_t size[4]; /*number of sample points */
- int i, j;
- char s[256];
-
- sprintf (s, "Testing image sampling %4lux%-4lu to %4lux%-4lu ",
- (unsigned long)(2*nx), (unsigned long)(2*ny),
- (unsigned long)nx, (unsigned long)ny);
- printf ("%-70s", s);
- fflush (stdout);
-
- /* Initialize */
- full = H5MM_xmalloc (4*nx*ny);
- init_full (full, 2*nx, 2*ny, 1);
- half = H5MM_xcalloc (nx*ny, 1);
- twice = H5MM_xcalloc (4*nx*ny, 1);
-
- /* Setup */
- size[0] = nx;
- size[1] = ny;
- src_stride[0] = 2*ny;
- src_stride[1] = 2;
- dst_stride[0] = 0;
- dst_stride[1] = 1;
-
- /* Copy */
- H5V_stride_copy (2, sizeof(uint8), size,
- dst_stride, half, src_stride, full);
-
- /* Check */
- for (i=0; i<nx; i++) {
- for (j=0; j<ny; j++) {
- if (full[4*i*ny + 2*j] != half[i*ny+j]) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" full[%d][%d] != half[%d][%d]\n", i*2, j*2, i, j);
- printf (" full is:\n");
- print_array (full, 2*nx, 2*ny, 1);
- printf ("\n half is:\n");
- print_array (half, nx, ny, 1);
- }
- goto error;
- }
- }
- }
- puts (" PASSED");
-
-
- /*
- * Test replicating pixels to produce an image twice as large in each
- * dimension.
- */
- sprintf (s, "Testing image sampling %4lux%-4lu to %4lux%-4lu ",
- (unsigned long)nx, (unsigned long)ny,
- (unsigned long)(2*nx), (unsigned long)(2*ny));
- printf ("%-70s", s);
- fflush (stdout);
-
- /* Setup stride */
- size[0] = nx;
- size[1] = ny;
- size[2] = 2;
- size[3] = 2;
- src_stride[0] = 0;
- src_stride[1] = 1;
- src_stride[2] = 0;
- src_stride[3] = 0;
- dst_stride[0] = 2*ny;
- dst_stride[1] = 2*sizeof(uint8) - 4*ny;
- dst_stride[2] = 2*ny - 2*sizeof(uint8);
- dst_stride[3] = sizeof(uint8);
-
- /* Copy */
- H5V_stride_copy (4, sizeof(uint8), size,
- dst_stride, twice, src_stride, half);
-
- /* Check */
- s[0] = '\0';
- for (i=0; i<nx; i++) {
- for (j=0; j<ny; j++) {
- if (half[i*ny+j] != twice[4*i*ny + 2*j]) {
- sprintf (s, "half[%d][%d] != twice[%d][%d]", i, j, 2*i, 2*j);
- } else if (half[i*ny+j] != twice[4*i*ny + 2*j + 1]) {
- sprintf (s, "half[%d][%d] != twice[%d][%d]", i, j, 2*i, 2*j+1);
- } else if (half[i*ny+j] != twice[(2*i+1)*2*ny + 2*j]) {
- sprintf (s, "half[%d][%d] != twice[%d][%d]", i, j, 2*i+1, 2*j);
- } else if (half[i*ny+j] != twice[(2*i+1)*2*ny + 2*j + 1]) {
- sprintf (s, "half[%d][%d] != twice[%d][%d]", i, j, 2*i+1, 2*j+1);
- }
- if (s[0]) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" %s\n Half is:\n", s);
- print_array (half, nx, ny, 1);
- printf ("\n Twice is:\n");
- print_array (twice, 2*nx, 2*ny, 1);
- }
- goto error;
- }
- }
- }
- puts (" PASSED");
-
-
- H5MM_xfree (full);
- H5MM_xfree (half);
- H5MM_xfree (twice);
- return SUCCEED;
-
- error:
- H5MM_xfree (full);
- H5MM_xfree (half);
- H5MM_xfree (twice);
- return FAIL;
+ uint8 *full = NULL; /*original image */
+ uint8 *half = NULL; /*image at 1/2 resolution */
+ uint8 *twice = NULL; /*2x2 pixels */
+ intn src_stride[4]; /*source stride info */
+ intn dst_stride[4]; /*destination stride info */
+ size_t size[4]; /*number of sample points */
+ int i, j;
+ char s[256];
+
+ sprintf(s, "Testing image sampling %4lux%-4lu to %4lux%-4lu ",
+ (unsigned long) (2 * nx), (unsigned long) (2 * ny),
+ (unsigned long) nx, (unsigned long) ny);
+ printf("%-70s", s);
+ fflush(stdout);
+
+ /* Initialize */
+ full = H5MM_xmalloc(4 * nx * ny);
+ init_full(full, 2 * nx, 2 * ny, 1);
+ half = H5MM_xcalloc(nx * ny, 1);
+ twice = H5MM_xcalloc(4 * nx * ny, 1);
+
+ /* Setup */
+ size[0] = nx;
+ size[1] = ny;
+ src_stride[0] = 2 * ny;
+ src_stride[1] = 2;
+ dst_stride[0] = 0;
+ dst_stride[1] = 1;
+
+ /* Copy */
+ H5V_stride_copy(2, sizeof(uint8), size,
+ dst_stride, half, src_stride, full);
+
+ /* Check */
+ for (i = 0; i < nx; i++) {
+ for (j = 0; j < ny; j++) {
+ if (full[4 * i * ny + 2 * j] != half[i * ny + j]) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" full[%d][%d] != half[%d][%d]\n", i * 2, j * 2, i, j);
+ printf(" full is:\n");
+ print_array(full, 2 * nx, 2 * ny, 1);
+ printf("\n half is:\n");
+ print_array(half, nx, ny, 1);
+ }
+ goto error;
+ }
+ }
+ }
+ puts(" PASSED");
+
+ /*
+ * Test replicating pixels to produce an image twice as large in each
+ * dimension.
+ */
+ sprintf(s, "Testing image sampling %4lux%-4lu to %4lux%-4lu ",
+ (unsigned long) nx, (unsigned long) ny,
+ (unsigned long) (2 * nx), (unsigned long) (2 * ny));
+ printf("%-70s", s);
+ fflush(stdout);
+
+ /* Setup stride */
+ size[0] = nx;
+ size[1] = ny;
+ size[2] = 2;
+ size[3] = 2;
+ src_stride[0] = 0;
+ src_stride[1] = 1;
+ src_stride[2] = 0;
+ src_stride[3] = 0;
+ dst_stride[0] = 2 * ny;
+ dst_stride[1] = 2 * sizeof(uint8) - 4 * ny;
+ dst_stride[2] = 2 * ny - 2 * sizeof(uint8);
+ dst_stride[3] = sizeof(uint8);
+
+ /* Copy */
+ H5V_stride_copy(4, sizeof(uint8), size,
+ dst_stride, twice, src_stride, half);
+
+ /* Check */
+ s[0] = '\0';
+ for (i = 0; i < nx; i++) {
+ for (j = 0; j < ny; j++) {
+ if (half[i * ny + j] != twice[4 * i * ny + 2 * j]) {
+ sprintf(s, "half[%d][%d] != twice[%d][%d]", i, j, 2 * i, 2 * j);
+ } else if (half[i * ny + j] != twice[4 * i * ny + 2 * j + 1]) {
+ sprintf(s, "half[%d][%d] != twice[%d][%d]", i, j, 2 * i, 2 * j + 1);
+ } else if (half[i * ny + j] != twice[(2 * i + 1) * 2 * ny + 2 * j]) {
+ sprintf(s, "half[%d][%d] != twice[%d][%d]", i, j, 2 * i + 1, 2 * j);
+ } else if (half[i * ny + j] != twice[(2 * i + 1) * 2 * ny + 2 * j + 1]) {
+ sprintf(s, "half[%d][%d] != twice[%d][%d]", i, j, 2 * i + 1, 2 * j + 1);
+ }
+ if (s[0]) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" %s\n Half is:\n", s);
+ print_array(half, nx, ny, 1);
+ printf("\n Twice is:\n");
+ print_array(twice, 2 * nx, 2 * ny, 1);
+ }
+ goto error;
+ }
+ }
+ }
+ puts(" PASSED");
+
+ H5MM_xfree(full);
+ H5MM_xfree(half);
+ H5MM_xfree(twice);
+ return SUCCEED;
+
+ error:
+ H5MM_xfree(full);
+ H5MM_xfree(half);
+ H5MM_xfree(twice);
+ return FAIL;
}
-
/*-------------------------------------------------------------------------
- * Function: main
+ * Function: main
*
- * Purpose: Test various hyperslab operations. Give the words
- * `small' and/or `medium' on the command line or only `small'
- * is assumed.
+ * Purpose: Test various hyperslab operations. Give the words
+ * `small' and/or `medium' on the command line or only `small'
+ * is assumed.
*
- * Return: Success: exit(0)
+ * Return: Success: exit(0)
*
- * Failure: exit(non-zero)
+ * Failure: exit(non-zero)
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, October 10, 1997
*
* Modifications:
@@ -1006,195 +987,179 @@ test_sub_super (size_t nx, size_t ny)
*-------------------------------------------------------------------------
*/
int
-main (int argc, char *argv[])
+main(int argc, char *argv[])
{
- herr_t status;
- int nerrors=0;
- uintn size_of_test;
-
- /* Parse arguments or assume `small' */
- if (1==argc) {
- size_of_test = TEST_SMALL;
- } else {
- intn i;
- for (i=1,size_of_test=0; i<argc; i++) {
- if (!strcmp (argv[i], "small")) {
- size_of_test |= TEST_SMALL;
- } else if (!strcmp (argv[i], "medium")) {
- size_of_test |= TEST_MEDIUM;
- } else {
- printf ("unrecognized argument: %s\n", argv[i]);
- exit (1);
- }
- }
- }
- printf ("Test sizes: ");
- if (size_of_test & TEST_SMALL) printf (" SMALL");
- if (size_of_test & TEST_MEDIUM) printf (" MEDIUM");
- printf ("\n");
-
-
-
- /*
- *------------------------------
- * TEST HYPERSLAB FILL OPERATION
- *------------------------------
- */
- if (size_of_test & TEST_SMALL) {
- status = test_fill (11, 0, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status<0 ? 1 : 0;
- status = test_fill (11, 10, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status<0 ? 1 : 0;
- status = test_fill (3, 5, 5, 1, 1, 1, 1, 1, 1);
- nerrors += status<0 ? 1 : 0;
- }
- if (size_of_test & TEST_MEDIUM) {
- status = test_fill (113, 0, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status<0 ? 1 : 0;
- status = test_fill (15, 11, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status<0 ? 1 : 0;
- status = test_fill (5, 7, 7, 1, 1, 1, 1, 1, 1);
- nerrors += status<0 ? 1 : 0;
- }
-
-
+ herr_t status;
+ int nerrors = 0;
+ uintn size_of_test;
+
+ /* Parse arguments or assume `small' */
+ if (1 == argc) {
+ size_of_test = TEST_SMALL;
+ } else {
+ intn i;
+ for (i = 1, size_of_test = 0; i < argc; i++) {
+ if (!strcmp(argv[i], "small")) {
+ size_of_test |= TEST_SMALL;
+ } else if (!strcmp(argv[i], "medium")) {
+ size_of_test |= TEST_MEDIUM;
+ } else {
+ printf("unrecognized argument: %s\n", argv[i]);
+ exit(1);
+ }
+ }
+ }
+ printf("Test sizes: ");
+ if (size_of_test & TEST_SMALL)
+ printf(" SMALL");
+ if (size_of_test & TEST_MEDIUM)
+ printf(" MEDIUM");
+ printf("\n");
+
+ /*
+ *------------------------------
+ * TEST HYPERSLAB FILL OPERATION
+ *------------------------------
+ */
+ if (size_of_test & TEST_SMALL) {
+ status = test_fill(11, 0, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_fill(11, 10, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_fill(3, 5, 5, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ }
+ if (size_of_test & TEST_MEDIUM) {
+ status = test_fill(113, 0, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_fill(15, 11, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_fill(5, 7, 7, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ }
/*------------------------------
* TEST HYPERSLAB COPY OPERATION
*------------------------------
*/
- /* exhaustive, one-dimensional test */
- if (size_of_test & TEST_SMALL) {
- status = test_copy (VARIABLE_SRC, 11, 0, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status<0 ? 1 : 0;
- status = test_copy (VARIABLE_DST, 11, 0, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status<0 ? 1 : 0;
- status = test_copy (VARIABLE_BOTH, 11, 0, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status<0 ? 1 : 0;
- }
- if (size_of_test & TEST_MEDIUM) {
- status = test_copy (VARIABLE_SRC, 179, 0, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status<0 ? 1 : 0;
- status = test_copy (VARIABLE_DST, 179, 0, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status<0 ? 1 : 0;
- status = test_copy (VARIABLE_BOTH, 179, 0, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status<0 ? 1 : 0;
- }
-
- /* exhaustive, two-dimensional test */
- if (size_of_test & TEST_SMALL) {
- status = test_copy (VARIABLE_SRC, 11, 10, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status<0 ? 1 : 0;
- status = test_copy (VARIABLE_DST, 11, 10, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status<0 ? 1 : 0;
- status = test_copy (VARIABLE_BOTH, 11, 10, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status<0 ? 1 : 0;
- }
- if (size_of_test & TEST_MEDIUM) {
- status = test_copy (VARIABLE_SRC, 13, 19, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status<0 ? 1 : 0;
- status = test_copy (VARIABLE_DST, 13, 19, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status<0 ? 1 : 0;
- status = test_copy (VARIABLE_BOTH, 13, 19, 0, 1, 1, 1, 1, 1, 1);
- nerrors += status<0 ? 1 : 0;
- }
-
- /* sparse, two-dimensional test */
- if (size_of_test & TEST_MEDIUM) {
- status = test_copy (VARIABLE_SRC, 73, 67, 0, 7, 11, 1, 13, 11, 1);
- nerrors += status<0 ? 1 : 0;
- status = test_copy (VARIABLE_DST, 73, 67, 0, 7, 11, 1, 13, 11, 1);
- nerrors += status<0 ? 1 : 0;
- status = test_copy (VARIABLE_BOTH, 73, 67, 0, 7, 11, 1, 13, 11, 1);
- nerrors += status<0 ? 1 : 0;
- }
-
-
- /* exhaustive, three-dimensional test */
- if (size_of_test & TEST_SMALL) {
- status = test_copy (VARIABLE_SRC, 3, 5, 5, 1, 1, 1, 1, 1, 1);
- nerrors += status<0 ? 1 : 0;
- status = test_copy (VARIABLE_DST, 3, 5, 5, 1, 1, 1, 1, 1, 1);
- nerrors += status<0 ? 1 : 0;
- status = test_copy (VARIABLE_BOTH, 3, 5, 5, 1, 1, 1, 1, 1, 1);
- nerrors += status<0 ? 1 : 0;
- }
- if (size_of_test & TEST_MEDIUM) {
- status = test_copy (VARIABLE_SRC, 7, 9, 5, 1, 1, 1, 1, 1, 1);
- nerrors += status<0 ? 1 : 0;
- status = test_copy (VARIABLE_DST, 7, 9, 5, 1, 1, 1, 1, 1, 1);
- nerrors += status<0 ? 1 : 0;
- status = test_copy (VARIABLE_BOTH, 7, 9, 5, 1, 1, 1, 1, 1, 1);
- nerrors += status<0 ? 1 : 0;
- }
-
-
+ /* exhaustive, one-dimensional test */
+ if (size_of_test & TEST_SMALL) {
+ status = test_copy(VARIABLE_SRC, 11, 0, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_DST, 11, 0, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_BOTH, 11, 0, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ }
+ if (size_of_test & TEST_MEDIUM) {
+ status = test_copy(VARIABLE_SRC, 179, 0, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_DST, 179, 0, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_BOTH, 179, 0, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ }
+ /* exhaustive, two-dimensional test */
+ if (size_of_test & TEST_SMALL) {
+ status = test_copy(VARIABLE_SRC, 11, 10, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_DST, 11, 10, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_BOTH, 11, 10, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ }
+ if (size_of_test & TEST_MEDIUM) {
+ status = test_copy(VARIABLE_SRC, 13, 19, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_DST, 13, 19, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_BOTH, 13, 19, 0, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ }
+ /* sparse, two-dimensional test */
+ if (size_of_test & TEST_MEDIUM) {
+ status = test_copy(VARIABLE_SRC, 73, 67, 0, 7, 11, 1, 13, 11, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_DST, 73, 67, 0, 7, 11, 1, 13, 11, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_BOTH, 73, 67, 0, 7, 11, 1, 13, 11, 1);
+ nerrors += status < 0 ? 1 : 0;
+ }
+ /* exhaustive, three-dimensional test */
+ if (size_of_test & TEST_SMALL) {
+ status = test_copy(VARIABLE_SRC, 3, 5, 5, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_DST, 3, 5, 5, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_BOTH, 3, 5, 5, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ }
+ if (size_of_test & TEST_MEDIUM) {
+ status = test_copy(VARIABLE_SRC, 7, 9, 5, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_DST, 7, 9, 5, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_copy(VARIABLE_BOTH, 7, 9, 5, 1, 1, 1, 1, 1, 1);
+ nerrors += status < 0 ? 1 : 0;
+ }
/*---------------------
* TEST MULTI-BYTE FILL
*---------------------
*/
- if (size_of_test & TEST_SMALL) {
- status = test_multifill (10);
- nerrors += status<0 ? 1 : 0;
- }
- if (size_of_test & TEST_MEDIUM) {
- status = test_multifill (500000);
- nerrors += status<0 ? 1 : 0;
- }
-
-
+ if (size_of_test & TEST_SMALL) {
+ status = test_multifill(10);
+ nerrors += status < 0 ? 1 : 0;
+ }
+ if (size_of_test & TEST_MEDIUM) {
+ status = test_multifill(500000);
+ nerrors += status < 0 ? 1 : 0;
+ }
/*---------------------------
* TEST TRANSLATION OPERATORS
*---------------------------
*/
- if (size_of_test & TEST_SMALL) {
- status = test_endian (10);
- nerrors += status<0 ? 1 : 0;
- status = test_transpose (9, 9);
- nerrors += status<0 ? 1 : 0;
- status = test_transpose (3, 11);
- nerrors += status<0 ? 1 : 0;
- }
- if (size_of_test & TEST_MEDIUM) {
- status = test_endian (800000);
- nerrors += status<0 ? 1 : 0;
- status = test_transpose (1200, 1200);
- nerrors += status<0 ? 1 : 0;
- status = test_transpose (800, 1800);
- nerrors += status<0 ? 1 : 0;
- }
-
-
+ if (size_of_test & TEST_SMALL) {
+ status = test_endian(10);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_transpose(9, 9);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_transpose(3, 11);
+ nerrors += status < 0 ? 1 : 0;
+ }
+ if (size_of_test & TEST_MEDIUM) {
+ status = test_endian(800000);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_transpose(1200, 1200);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_transpose(800, 1800);
+ nerrors += status < 0 ? 1 : 0;
+ }
/*-------------------------
* TEST SAMPLING OPERATIONS
*-------------------------
*/
-
- if (size_of_test & TEST_SMALL) {
- status = test_sub_super (5, 10);
- nerrors += status<0 ? 1 : 0;
- }
- if (size_of_test & TEST_MEDIUM) {
- status = test_sub_super (480, 640);
- nerrors += status<0 ? 1 : 0;
- }
-
-
-
- /*--- END OF TESTS ---*/
-
- if (nerrors) {
- printf ("***** %d HYPERSLAB TEST%s FAILED! *****\n",
- nerrors, 1==nerrors?"":"S");
- if (isatty (1)) {
- printf ("(Redirect output to a pager or a file to see "
- "debug output)\n");
- }
- exit (1);
- }
-
- printf ("All hyperslab tests passed.\n");
- exit (0);
+
+ if (size_of_test & TEST_SMALL) {
+ status = test_sub_super(5, 10);
+ nerrors += status < 0 ? 1 : 0;
+ }
+ if (size_of_test & TEST_MEDIUM) {
+ status = test_sub_super(480, 640);
+ nerrors += status < 0 ? 1 : 0;
+ }
+/*--- END OF TESTS ---*/
+
+ if (nerrors) {
+ printf("***** %d HYPERSLAB TEST%s FAILED! *****\n",
+ nerrors, 1 == nerrors ? "" : "S");
+ if (isatty(1)) {
+ printf("(Redirect output to a pager or a file to see "
+ "debug output)\n");
+ }
+ exit(1);
+ }
+ printf("All hyperslab tests passed.\n");
+ exit(0);
}
diff --git a/test/istore.c b/test/istore.c
index 8f246c8..6115a5f 100644
--- a/test/istore.c
+++ b/test/istore.c
@@ -2,10 +2,10 @@
* Copyright (C) 1997 NCSA
* All rights reserved.
*
- * Programmer: Robb Matzke <matzke@llnl.gov>
- * Wednesday, October 15, 1997
+ * Programmer: Robb Matzke <matzke@llnl.gov>
+ * Wednesday, October 15, 1997
*
- * Purpose: Tests various aspects of indexed raw data storage.
+ * Purpose: Tests various aspects of indexed raw data storage.
*/
#include <H5private.h>
#include <H5Cprivate.h>
@@ -16,38 +16,38 @@
#include <H5Vprivate.h>
#if 1
-# define FILETYPE H5F_LOW_DFLT
-# define FILENAME "istore.h5"
+# define FILETYPE H5F_LOW_DFLT
+# define FILENAME "istore.h5"
#elif 0
-# define FILETYPE H5F_LOW_FAM
-# define FILENAME "istore-%05d.h5"
-# define TEST_FAMILY 1
+# define FILETYPE H5F_LOW_FAM
+# define FILENAME "istore-%05d.h5"
+# define TEST_FAMILY 1
#else
-# define FILETYPE H5F_LOW_SPLIT
-# define FILENAME "istore-split"
+# define FILETYPE H5F_LOW_SPLIT
+# define FILENAME "istore-split"
#endif
-#define TEST_SMALL 0x0001
-#define TEST_MEDIUM 0x0002
-#define TEST_LARGE 0x0004
+#define TEST_SMALL 0x0001
+#define TEST_MEDIUM 0x0002
+#define TEST_LARGE 0x0004
#ifndef HAVE_FUNCTION
#define __FUNCTION__ ""
#endif
-#define AT() printf (" at %s:%d in %s()...\n", \
- __FILE__, __LINE__, __FUNCTION__);
-
-size_t align_g[3] = {50, 50, 50};
+#define AT() printf (" at %s:%d in %s()...\n", \
+ __FILE__, __LINE__, __FUNCTION__);
+size_t align_g[3] =
+{50, 50, 50};
/*-------------------------------------------------------------------------
- * Function: print_array
+ * Function: print_array
*
- * Purpose: Prints the values in an array
+ * Purpose: Prints the values in an array
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, October 10, 1997
*
* Modifications:
@@ -55,41 +55,41 @@ size_t align_g[3] = {50, 50, 50};
*-------------------------------------------------------------------------
*/
static void
-print_array (uint8 *array, size_t nx, size_t ny, size_t nz)
+print_array(uint8 *array, size_t nx, size_t ny, size_t nz)
{
- int i, j, k;
-
- for (i=0; i<nx; i++) {
- if (nz>1) {
- printf ("i=%d:\n", i);
- } else {
- printf ("%03d:", i);
- }
-
- for (j=0; j<ny; j++) {
- if (nz>1) printf ("%03d:", j);
- for (k=0; k<nz; k++) {
- printf (" %3d", *array++);
- }
- if (nz>1) printf ("\n");
- }
- printf ("\n");
- }
+ int i, j, k;
+
+ for (i = 0; i < nx; i++) {
+ if (nz > 1) {
+ printf("i=%d:\n", i);
+ } else {
+ printf("%03d:", i);
+ }
+
+ for (j = 0; j < ny; j++) {
+ if (nz > 1)
+ printf("%03d:", j);
+ for (k = 0; k < nz; k++) {
+ printf(" %3d", *array++);
+ }
+ if (nz > 1)
+ printf("\n");
+ }
+ printf("\n");
+ }
}
-
-
/*-------------------------------------------------------------------------
- * Function: new_object
+ * Function: new_object
*
- * Purpose: Creates a new object that refers to a indexed storage of raw
- * data. No raw data is stored.
+ * Purpose: Creates a new object that refers to a indexed storage of raw
+ * data. No raw data is stored.
*
- * Return: Success: Handle to a new open object.
+ * Return: Success: Handle to a new open object.
*
- * Failure: NULL, error message printed.
+ * Failure: NULL, error message printed.
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 15, 1997
*
* Modifications:
@@ -97,69 +97,65 @@ print_array (uint8 *array, size_t nx, size_t ny, size_t nz)
*-------------------------------------------------------------------------
*/
static int
-new_object (H5F_t *f, const char *name, size_t ndims, H5G_entry_t *ent/*out*/)
+new_object(H5F_t *f, const char *name, size_t ndims, H5G_entry_t *ent /*out */ )
{
- H5O_layout_t layout;
- intn i;
-
- /* Create the object header */
- if (H5O_create (f, 64, ent)) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" H5O_create() = NULL\n");
- }
- return -1;
- }
-
- /* create chunked storage */
- layout.type = H5D_CHUNKED;
- layout.ndims = ndims;
- for (i=0; i<ndims; i++) {
- if (i<NELMTS (align_g)) {
- layout.dim[i] = align_g[i];
- } else {
- layout.dim[i] = 2;
- }
- }
- H5F_arr_create (f, &layout/*in,out*/);
- if (H5O_modify (ent, H5O_LAYOUT, H5O_NEW_MESG, 0, &layout)<0) {
- printf ("*FAILED*\n");
- if (!isatty (1)) {
- AT();
- printf (" H5O_modify istore message failure\n");
- }
- return -1;
- }
-
- /* Give the object header a name */
- if (H5G_insert (name, ent)<0) {
- printf ("*FAILED*\n");
- if (!isatty (1)) {
- AT ();
- printf (" H5G_insert(f, name=\"%s\", ent) failed\n", name);
- }
- return -1;
- }
-
- /* Close the header */
- H5O_close (ent);
-
- return 0;
+ H5O_layout_t layout;
+ intn i;
+
+ /* Create the object header */
+ if (H5O_create(f, 64, ent)) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" H5O_create() = NULL\n");
+ }
+ return -1;
+ }
+ /* create chunked storage */
+ layout.type = H5D_CHUNKED;
+ layout.ndims = ndims;
+ for (i = 0; i < ndims; i++) {
+ if (i < NELMTS(align_g)) {
+ layout.dim[i] = align_g[i];
+ } else {
+ layout.dim[i] = 2;
+ }
+ }
+ H5F_arr_create(f, &layout /*in,out */ );
+ if (H5O_modify(ent, H5O_LAYOUT, H5O_NEW_MESG, 0, &layout) < 0) {
+ printf("*FAILED*\n");
+ if (!isatty(1)) {
+ AT();
+ printf(" H5O_modify istore message failure\n");
+ }
+ return -1;
+ }
+ /* Give the object header a name */
+ if (H5G_insert(name, ent) < 0) {
+ printf("*FAILED*\n");
+ if (!isatty(1)) {
+ AT();
+ printf(" H5G_insert(f, name=\"%s\", ent) failed\n", name);
+ }
+ return -1;
+ }
+ /* Close the header */
+ H5O_close(ent);
+
+ return 0;
}
-
/*-------------------------------------------------------------------------
- * Function: test_create
+ * Function: test_create
*
- * Purpose: Creates a named object that refers to indexed storage of raw
- * data. No raw data is stored.
+ * Purpose: Creates a named object that refers to indexed storage of raw
+ * data. No raw data is stored.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 15, 1997
*
* Modifications:
@@ -167,37 +163,36 @@ new_object (H5F_t *f, const char *name, size_t ndims, H5G_entry_t *ent/*out*/)
*-------------------------------------------------------------------------
*/
static herr_t
-test_create (H5F_t *f, const char *prefix)
+test_create(H5F_t *f, const char *prefix)
{
- H5G_entry_t handle;
- intn i;
- char name[256];
-
- printf ("%-70s", "Testing istore create");
-
- for (i=1; i<=H5O_LAYOUT_NDIMS; i++) {
- sprintf (name, "%s_%02d", prefix, i);
- if (new_object (f, name, i, &handle)<0) return FAIL;
- }
-
- puts (" PASSED");
- return SUCCEED;
-}
+ H5G_entry_t handle;
+ intn i;
+ char name[256];
+ printf("%-70s", "Testing istore create");
+ for (i = 1; i <= H5O_LAYOUT_NDIMS; i++) {
+ sprintf(name, "%s_%02d", prefix, i);
+ if (new_object(f, name, i, &handle) < 0)
+ return FAIL;
+ }
+
+ puts(" PASSED");
+ return SUCCEED;
+}
/*-------------------------------------------------------------------------
- * Function: test_extend
+ * Function: test_extend
*
- * Purpose: Creates an empty object and then writes to it in such a way
- * as to always extend the object's domain without creating
- * holes and without causing the object to become concave.
+ * Purpose: Creates an empty object and then writes to it in such a way
+ * as to always extend the object's domain without creating
+ * holes and without causing the object to become concave.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 15, 1997
*
* Modifications:
@@ -205,214 +200,217 @@ test_create (H5F_t *f, const char *prefix)
*-------------------------------------------------------------------------
*/
static herr_t
-test_extend (H5F_t *f, const char *prefix,
- size_t nx, size_t ny, size_t nz)
+test_extend(H5F_t *f, const char *prefix,
+ size_t nx, size_t ny, size_t nz)
{
- H5G_entry_t handle;
- int i, j, k, ndims, ctr;
- uint8 *buf=NULL, *check=NULL, *whole=NULL;
- char dims[64], s[256], name[256];
- size_t offset[3];
- size_t max_corner[3];
- size_t size[3];
- size_t whole_size[3];
- size_t nelmts;
- H5O_layout_t layout;
-
- if (!nz) {
- if (!ny) {
- ndims = 1;
- ny = nz = 1;
- sprintf (dims, "%lu", (unsigned long)nx);
- } else {
- ndims = 2;
- nz = 1;
- sprintf (dims, "%lux%lu", (unsigned long)nx, (unsigned long)ny);
- }
- } else {
- ndims = 3;
- sprintf (dims, "%lux%lux%lu",
- (unsigned long)nx, (unsigned long)ny, (unsigned long)nz);
- }
-
-
- sprintf (s, "Testing istore extend: %s", dims);
- printf ("%-70s", s);
- buf = H5MM_xmalloc (nx*ny*nz);
- check = H5MM_xmalloc (nx*ny*nz);
- whole = H5MM_xcalloc (nx*ny*nz, 1);
-
- /* Build the new empty object */
- sprintf (name, "%s_%s", prefix, dims);
- if (new_object (f, name, ndims, &handle)<0) {
- if (!isatty (1)) {
- AT ();
- printf (" Cannot create %d-d object `%s'\n", ndims, name);
- }
- goto error;
- }
- if (NULL==H5O_read (&handle, H5O_LAYOUT, 0, &layout)) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Unable to read istore message\n");
- }
- goto error;
- }
- if (ndims!=layout.ndims) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Header read error: istore.ndims != %d\n", ndims);
- }
- goto error;
- }
-
- whole_size[0] = nx;
- whole_size[1] = ny;
- whole_size[2] = nz;
- max_corner[0] = 0;
- max_corner[1] = 0;
- max_corner[2] = 0;
-
- for (ctr=0; H5V_vector_lt (ndims, max_corner, whole_size); ctr++) {
-
- /* Size and location */
- if (0==ctr) {
- offset[0] = offset[1] = offset[2] = 0;
- size[0] = size[1] = size[2] = 1;
- nelmts = 1;
- } else {
- for (i=0, nelmts=1; i<ndims; i++) {
- if (ctr % ndims == i) {
- offset[i] = max_corner[i];
- size[i] = MIN (1, whole_size[i]-offset[i]);
- } else {
- offset[i] = 0;
- size[i] = max_corner[i];
- }
- nelmts *= size[i];
- }
- }
+ H5G_entry_t handle;
+ int i, j, k, ndims, ctr;
+ uint8 *buf = NULL, *check = NULL, *whole = NULL;
+ char dims[64], s[256], name[256];
+ size_t offset[3];
+ size_t max_corner[3];
+ size_t size[3];
+ size_t whole_size[3];
+ size_t nelmts;
+ H5O_layout_t layout;
+
+ if (!nz) {
+ if (!ny) {
+ ndims = 1;
+ ny = nz = 1;
+ sprintf(dims, "%lu", (unsigned long) nx);
+ } else {
+ ndims = 2;
+ nz = 1;
+ sprintf(dims, "%lux%lu", (unsigned long) nx, (unsigned long) ny);
+ }
+ } else {
+ ndims = 3;
+ sprintf(dims, "%lux%lux%lu",
+ (unsigned long) nx, (unsigned long) ny, (unsigned long) nz);
+ }
+
+ sprintf(s, "Testing istore extend: %s", dims);
+ printf("%-70s", s);
+ buf = H5MM_xmalloc(nx * ny * nz);
+ check = H5MM_xmalloc(nx * ny * nz);
+ whole = H5MM_xcalloc(nx * ny * nz, 1);
+
+ /* Build the new empty object */
+ sprintf(name, "%s_%s", prefix, dims);
+ if (new_object(f, name, ndims, &handle) < 0) {
+ if (!isatty(1)) {
+ AT();
+ printf(" Cannot create %d-d object `%s'\n", ndims, name);
+ }
+ goto error;
+ }
+ if (NULL == H5O_read(&handle, H5O_LAYOUT, 0, &layout)) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Unable to read istore message\n");
+ }
+ goto error;
+ }
+ if (ndims != layout.ndims) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Header read error: istore.ndims != %d\n", ndims);
+ }
+ goto error;
+ }
+ whole_size[0] = nx;
+ whole_size[1] = ny;
+ whole_size[2] = nz;
+ max_corner[0] = 0;
+ max_corner[1] = 0;
+ max_corner[2] = 0;
+
+ for (ctr = 0; H5V_vector_lt(ndims, max_corner, whole_size); ctr++) {
+
+ /* Size and location */
+ if (0 == ctr) {
+ offset[0] = offset[1] = offset[2] = 0;
+ size[0] = size[1] = size[2] = 1;
+ nelmts = 1;
+ } else {
+ for (i = 0, nelmts = 1; i < ndims; i++) {
+ if (ctr % ndims == i) {
+ offset[i] = max_corner[i];
+ size[i] = MIN(1, whole_size[i] - offset[i]);
+ } else {
+ offset[i] = 0;
+ size[i] = max_corner[i];
+ }
+ nelmts *= size[i];
+ }
+ }
#if 0
- if (0==ctr) printf ("\n");
- printf (" Insert: ctr=%d, corner=(%d", ctr, offset[0]);
- if (ndims>1) printf (",%d", offset[1]);
- if (ndims>2) printf (",%d", offset[2]);
- printf ("), size=(%d", size[0]);
- if (ndims>1) printf (",%d", size[1]);
- if (ndims>2) printf (",%d", size[2]);
- printf ("), %d element%s", nelmts, 1==nelmts?"":"s");
- if (0==nelmts) printf (" *SKIPPED*");
- printf ("\n");
+ if (0 == ctr)
+ printf("\n");
+ printf(" Insert: ctr=%d, corner=(%d", ctr, offset[0]);
+ if (ndims > 1)
+ printf(",%d", offset[1]);
+ if (ndims > 2)
+ printf(",%d", offset[2]);
+ printf("), size=(%d", size[0]);
+ if (ndims > 1)
+ printf(",%d", size[1]);
+ if (ndims > 2)
+ printf(",%d", size[2]);
+ printf("), %d element%s", nelmts, 1 == nelmts ? "" : "s");
+ if (0 == nelmts)
+ printf(" *SKIPPED*");
+ printf("\n");
#endif
-
- /* Fill the source array */
- if (0==nelmts) continue;
- memset (buf, 128+ctr, nelmts);
-
- /* Write to disk */
- if (H5F_arr_write (f, &layout, offset, size, buf)<0) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Write failed: ctr=%d\n", ctr);
- }
- goto error;
- }
-
- /* Read from disk */
- memset (check, 0xff, nelmts);
- if (H5F_arr_read (f, &layout, offset, size, check)<0) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Read failed: ctr=%d\n", ctr);
- }
- goto error;
- }
- if (memcmp (buf, check, nelmts)) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Read check failed: ctr=%d\n", ctr);
- printf (" Wrote:\n");
- print_array (buf, size[0], size[1], size[2]);
- printf (" Read:\n");
- print_array (check, size[0], size[1], size[2]);
- }
- goto error;
- }
-
- /* Write to `whole' buffer for later checking */
- H5V_hyper_copy (ndims, size,
- whole_size, offset, whole, /*dst*/
- size, H5V_ZERO, buf); /*src*/
-
- /* Update max corner */
- for (i=0; i<ndims; i++) {
- max_corner[i] = MAX (max_corner[i], offset[i]+size[i]);
- }
- }
-
- /* Now read the entire array back out and check it */
- memset (buf, 0xff, nx*ny*nz);
- if (H5F_arr_read (f, &layout, H5V_ZERO, whole_size, buf)<0) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Read failed for whole array\n");
- }
- goto error;
- }
- for (i=0; i<nx; i++) {
- for (j=0; j<ny; j++) {
- for (k=0; k<nz; k++) {
- if (whole[i*ny*nz + j*nz + k] != buf[i*ny*nz + j*nz + k]) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Check failed at i=%d", i);
- if (ndims>1) printf (", j=%d", j);
- if (ndims>2) printf (", k=%d", k);
- printf ("\n Check array is:\n");
- print_array (whole, nx, ny, nz);
- printf (" Value read is:\n");
- print_array (buf, nx, ny, nz);
- }
- goto error;
- }
- }
- }
- }
-
- puts (" PASSED");
- H5MM_xfree (buf);
- H5MM_xfree (check);
- H5MM_xfree (whole);
- return SUCCEED;
-
- error:
- H5MM_xfree (buf);
- H5MM_xfree (check);
- H5MM_xfree (whole);
- return FAIL;
-}
-
+ /* Fill the source array */
+ if (0 == nelmts)
+ continue;
+ memset(buf, 128 + ctr, nelmts);
+
+ /* Write to disk */
+ if (H5F_arr_write(f, &layout, offset, size, buf) < 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Write failed: ctr=%d\n", ctr);
+ }
+ goto error;
+ }
+ /* Read from disk */
+ memset(check, 0xff, nelmts);
+ if (H5F_arr_read(f, &layout, offset, size, check) < 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Read failed: ctr=%d\n", ctr);
+ }
+ goto error;
+ }
+ if (memcmp(buf, check, nelmts)) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Read check failed: ctr=%d\n", ctr);
+ printf(" Wrote:\n");
+ print_array(buf, size[0], size[1], size[2]);
+ printf(" Read:\n");
+ print_array(check, size[0], size[1], size[2]);
+ }
+ goto error;
+ }
+ /* Write to `whole' buffer for later checking */
+ H5V_hyper_copy(ndims, size,
+ whole_size, offset, whole, /*dst */
+ size, H5V_ZERO, buf); /*src */
+
+ /* Update max corner */
+ for (i = 0; i < ndims; i++) {
+ max_corner[i] = MAX(max_corner[i], offset[i] + size[i]);
+ }
+ }
+
+ /* Now read the entire array back out and check it */
+ memset(buf, 0xff, nx * ny * nz);
+ if (H5F_arr_read(f, &layout, H5V_ZERO, whole_size, buf) < 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Read failed for whole array\n");
+ }
+ goto error;
+ }
+ for (i = 0; i < nx; i++) {
+ for (j = 0; j < ny; j++) {
+ for (k = 0; k < nz; k++) {
+ if (whole[i * ny * nz + j * nz + k] != buf[i * ny * nz + j * nz + k]) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Check failed at i=%d", i);
+ if (ndims > 1)
+ printf(", j=%d", j);
+ if (ndims > 2)
+ printf(", k=%d", k);
+ printf("\n Check array is:\n");
+ print_array(whole, nx, ny, nz);
+ printf(" Value read is:\n");
+ print_array(buf, nx, ny, nz);
+ }
+ goto error;
+ }
+ }
+ }
+ }
+
+ puts(" PASSED");
+ H5MM_xfree(buf);
+ H5MM_xfree(check);
+ H5MM_xfree(whole);
+ return SUCCEED;
+
+ error:
+ H5MM_xfree(buf);
+ H5MM_xfree(check);
+ H5MM_xfree(whole);
+ return FAIL;
+}
/*-------------------------------------------------------------------------
- * Function: test_sparse
+ * Function: test_sparse
*
- * Purpose: Creates a sparse matrix consisting of NBLOCKS randomly placed
- * blocks each of size NX,NY,NZ.
+ * Purpose: Creates a sparse matrix consisting of NBLOCKS randomly placed
+ * blocks each of size NX,NY,NZ.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 22, 1997
*
* Modifications:
@@ -420,108 +418,109 @@ test_extend (H5F_t *f, const char *prefix,
*-------------------------------------------------------------------------
*/
static herr_t
-test_sparse (H5F_t *f, const char *prefix, size_t nblocks,
- size_t nx, size_t ny, size_t nz)
+test_sparse(H5F_t *f, const char *prefix, size_t nblocks,
+ size_t nx, size_t ny, size_t nz)
{
- intn ndims, ctr;
- char dims[64], s[256], name[256];
- size_t offset[3], size[3], total=0;
- H5G_entry_t handle;
- H5O_layout_t layout;
- uint8 *buf = NULL;
-
- if (!nz) {
- if (!ny) {
- ndims = 1;
- ny = nz = 1;
- sprintf (dims, "%lu", (unsigned long)nx);
- } else {
- ndims = 2;
- nz = 1;
- sprintf (dims, "%lux%lu", (unsigned long)nx, (unsigned long)ny);
- }
- } else {
- ndims = 3;
- sprintf (dims, "%lux%lux%lu",
- (unsigned long)nx, (unsigned long)ny, (unsigned long)nz);
- }
-
- sprintf (s, "Testing istore sparse: %s", dims);
- printf ("%-70s", s);
- buf = H5MM_xmalloc (nx*ny*nz);
-
- /* Build the new empty object */
- sprintf (name, "%s_%s", prefix, dims);
- if (new_object (f, name, ndims, &handle)<0) {
- if (!isatty (1)) {
- AT ();
- printf (" Cannot create %d-d object `%s'\n", ndims, name);
- }
- goto error;
- }
- if (NULL==H5O_read (&handle, H5O_LAYOUT, 0, &layout)) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Unable to read istore message\n");
- }
- goto error;
- }
-
- for (ctr=0; ctr<nblocks; ctr++) {
- offset[0] = rand () % 1000000;
- offset[1] = rand () % 1000000;
- offset[2] = rand () % 1000000;
- size[0] = nx;
- size[1] = ny;
- size[2] = nz;
- memset (buf, 128+ctr, nx*ny*nz);
-
- /* write to disk */
- if (H5F_arr_write (f, &layout, offset, size, buf)<0) {
- puts ("*FAILED*");
- if (!isatty (1)) {
- AT ();
- printf (" Write failed: ctr=%d\n", ctr);
- printf (" offset=(%lu", (unsigned long)(offset[0]));
- if (ndims>1) printf (",%lu", (unsigned long)(offset[1]));
- if (ndims>2) printf (",%lu", (unsigned long)(offset[2]));
- printf ("), size=(%lu", (unsigned long)(size[0]));
- if (ndims>1) printf (",%lu", (unsigned long)(size[1]));
- if (ndims>2) printf (",%lu", (unsigned long)(size[2]));
- printf (")\n");
- }
- goto error;
- }
- total += nx*ny*nz;
+ intn ndims, ctr;
+ char dims[64], s[256], name[256];
+ size_t offset[3], size[3], total = 0;
+ H5G_entry_t handle;
+ H5O_layout_t layout;
+ uint8 *buf = NULL;
+
+ if (!nz) {
+ if (!ny) {
+ ndims = 1;
+ ny = nz = 1;
+ sprintf(dims, "%lu", (unsigned long) nx);
+ } else {
+ ndims = 2;
+ nz = 1;
+ sprintf(dims, "%lux%lu", (unsigned long) nx, (unsigned long) ny);
+ }
+ } else {
+ ndims = 3;
+ sprintf(dims, "%lux%lux%lu",
+ (unsigned long) nx, (unsigned long) ny, (unsigned long) nz);
+ }
+
+ sprintf(s, "Testing istore sparse: %s", dims);
+ printf("%-70s", s);
+ buf = H5MM_xmalloc(nx * ny * nz);
+
+ /* Build the new empty object */
+ sprintf(name, "%s_%s", prefix, dims);
+ if (new_object(f, name, ndims, &handle) < 0) {
+ if (!isatty(1)) {
+ AT();
+ printf(" Cannot create %d-d object `%s'\n", ndims, name);
+ }
+ goto error;
+ }
+ if (NULL == H5O_read(&handle, H5O_LAYOUT, 0, &layout)) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Unable to read istore message\n");
+ }
+ goto error;
+ }
+ for (ctr = 0; ctr < nblocks; ctr++) {
+ offset[0] = rand() % 1000000;
+ offset[1] = rand() % 1000000;
+ offset[2] = rand() % 1000000;
+ size[0] = nx;
+ size[1] = ny;
+ size[2] = nz;
+ memset(buf, 128 + ctr, nx * ny * nz);
+
+ /* write to disk */
+ if (H5F_arr_write(f, &layout, offset, size, buf) < 0) {
+ puts("*FAILED*");
+ if (!isatty(1)) {
+ AT();
+ printf(" Write failed: ctr=%d\n", ctr);
+ printf(" offset=(%lu", (unsigned long) (offset[0]));
+ if (ndims > 1)
+ printf(",%lu", (unsigned long) (offset[1]));
+ if (ndims > 2)
+ printf(",%lu", (unsigned long) (offset[2]));
+ printf("), size=(%lu", (unsigned long) (size[0]));
+ if (ndims > 1)
+ printf(",%lu", (unsigned long) (size[1]));
+ if (ndims > 2)
+ printf(",%lu", (unsigned long) (size[2]));
+ printf(")\n");
+ }
+ goto error;
+ }
+ total += nx * ny * nz;
#if 0
- printf ("ctr: ctr=%d, total=%lu\n", ctr, (unsigned long)total);
+ printf("ctr: ctr=%d, total=%lu\n", ctr, (unsigned long) total);
#endif
- /* We don't test reading yet.... */
- }
-
-
- puts (" PASSED");
- H5MM_xfree (buf);
- return SUCCEED;
-
- error:
- H5MM_xfree (buf);
- return FAIL;
-}
+ /* We don't test reading yet.... */
+ }
+ puts(" PASSED");
+ H5MM_xfree(buf);
+ return SUCCEED;
+
+ error:
+ H5MM_xfree(buf);
+ return FAIL;
+}
/*-------------------------------------------------------------------------
- * Function: main
+ * Function: main
*
- * Purpose: Tests indexed storage stuff.
+ * Purpose: Tests indexed storage stuff.
*
- * Return: Success: exit(0)
+ * Return: Success: exit(0)
*
- * Failure: exit(non-zero)
+ * Failure: exit(non-zero)
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 15, 1997
*
* Modifications:
@@ -529,136 +528,134 @@ test_sparse (H5F_t *f, const char *prefix, size_t nblocks,
*-------------------------------------------------------------------------
*/
int
-main (int argc, char *argv[])
+main(int argc, char *argv[])
{
- H5F_t *f;
- herr_t status;
- int nerrors = 0;
- uintn size_of_test;
- hid_t template_id;
- H5F_create_t *creation_template = NULL;
- H5G_t *dir = NULL;
-
- setbuf (stdout, NULL);
-
- /* Parse arguments or assume `small' */
- if (1==argc) {
- size_of_test = TEST_SMALL;
- } else {
- intn i;
- for (i=1,size_of_test=0; i<argc; i++) {
- if (!strcmp (argv[i], "small")) {
- size_of_test |= TEST_SMALL;
- } else if (!strcmp (argv[i], "medium")) {
- size_of_test |= TEST_MEDIUM;
- } else if (!strcmp (argv[i], "large")) {
- size_of_test |= TEST_LARGE;
- } else {
- printf ("unrecognized argument: %s\n", argv[i]);
- exit (1);
- }
- }
- }
- printf ("Test sizes: ");
- if (size_of_test & TEST_SMALL) printf (" SMALL");
- if (size_of_test & TEST_MEDIUM) printf (" MEDIUM");
- if (size_of_test & TEST_LARGE) printf (" LARGE");
- printf ("\n");
-
- /*
- * Use larger file addresses...
- */
- template_id = H5Ccreate (H5C_FILE_CREATE);
- H5Cset_sizes (template_id, 8, 0);
- creation_template = H5Aatom_object (template_id);
-
- /* Create the test file */
- if (NULL==(f=H5F_open (FILETYPE, FILENAME,
- (H5F_ACC_CREAT|H5F_ACC_WRITE|H5F_ACC_TRUNC|
- H5F_ACC_DEBUG),
- creation_template))) {
- printf ("Cannot create file %s; test aborted\n", FILENAME);
- exit (1);
- }
-
+ H5F_t *f;
+ herr_t status;
+ int nerrors = 0;
+ uintn size_of_test;
+ hid_t template_id;
+ H5F_create_t *creation_template = NULL;
+ H5G_t *dir = NULL;
+
+ setbuf(stdout, NULL);
+
+ /* Parse arguments or assume `small' */
+ if (1 == argc) {
+ size_of_test = TEST_SMALL;
+ } else {
+ intn i;
+ for (i = 1, size_of_test = 0; i < argc; i++) {
+ if (!strcmp(argv[i], "small")) {
+ size_of_test |= TEST_SMALL;
+ } else if (!strcmp(argv[i], "medium")) {
+ size_of_test |= TEST_MEDIUM;
+ } else if (!strcmp(argv[i], "large")) {
+ size_of_test |= TEST_LARGE;
+ } else {
+ printf("unrecognized argument: %s\n", argv[i]);
+ exit(1);
+ }
+ }
+ }
+ printf("Test sizes: ");
+ if (size_of_test & TEST_SMALL)
+ printf(" SMALL");
+ if (size_of_test & TEST_MEDIUM)
+ printf(" MEDIUM");
+ if (size_of_test & TEST_LARGE)
+ printf(" LARGE");
+ printf("\n");
+
+ /*
+ * Use larger file addresses...
+ */
+ template_id = H5Ccreate(H5C_FILE_CREATE);
+ H5Cset_sizes(template_id, 8, 0);
+ creation_template = H5Aatom_object(template_id);
+
+ /* Create the test file */
+ if (NULL == (f = H5F_open(FILETYPE, FILENAME,
+ (H5F_ACC_CREAT | H5F_ACC_WRITE | H5F_ACC_TRUNC |
+ H5F_ACC_DEBUG),
+ creation_template))) {
+ printf("Cannot create file %s; test aborted\n", FILENAME);
+ exit(1);
+ }
#ifdef TEST_FAMILY
- {
- /*
- * For testing file families, fool the library into thinking it already
- * allocated a whole bunch of data.
- */
- haddr_t addr;
- addr.offset = 8 * ((uint64)1<<30); /*8 GB*/
- H5F_low_seteof (f->shared->lf, &addr);
- }
+ {
+ /*
+ * For testing file families, fool the library into thinking it already
+ * allocated a whole bunch of data.
+ */
+ haddr_t addr;
+ addr.offset = 8 * ((uint64) 1 << 30); /*8 GB */
+ H5F_low_seteof(f->shared->lf, &addr);
+ }
#endif
- /*
- * By creating a group we cause the library to emit it's debugging
- * diagnostic messages before we begin testing...
- */
- dir = H5G_create (f, "flushing_diagnostics", 0);
- H5G_close (dir);
- dir = NULL;
-
-
- /*
- * Creation test: Creates empty objects with various raw data sizes
- * and alignments.
- */
- status = test_create (f, "create");
- nerrors += status<0 ? 1 : 0;
-
- if (size_of_test & TEST_SMALL) {
- status = test_extend (f, "extend", 10, 0, 0);
- nerrors += status<0 ? 1 : 0;
- status = test_extend (f, "extend", 10, 10, 0);
- nerrors += status<0 ? 1 : 0;
- status = test_extend (f, "extend", 10, 10, 10);
- nerrors += status<0 ? 1 : 0;
- }
- if (size_of_test & TEST_MEDIUM) {
- status = test_extend (f, "extend", 10000, 0, 0);
- nerrors += status<0 ? 1 : 0;
- status = test_extend (f, "extend", 2500, 10, 0);
- nerrors += status<0 ? 1 : 0;
- status = test_extend (f, "extend", 10, 400, 10);
- nerrors += status<0 ? 1 : 0;
- }
- if (size_of_test & TEST_SMALL) {
- status = test_sparse (f, "sparse", 100, 5, 0, 0);
- nerrors += status<0 ? 1 : 0;
- status = test_sparse (f, "sparse", 100, 3, 4, 0);
- nerrors += status<0 ? 1 : 0;
- status = test_sparse (f, "sparse", 100, 2, 3, 4);
- nerrors += status<0 ? 1 : 0;
- }
- if (size_of_test & TEST_MEDIUM) {
- status = test_sparse (f, "sparse", 1000, 30, 0, 0);
- nerrors += status<0 ? 1 : 0;
- status = test_sparse (f, "sparse", 2000, 7, 3, 0);
- nerrors += status<0 ? 1 : 0;
- status = test_sparse (f, "sparse", 2000, 4, 2, 3);
- nerrors += status<0 ? 1 : 0;
- }
- if (size_of_test & TEST_LARGE) {
- status = test_sparse (f, "sparse", 800, 50, 50, 50);
- nerrors += status<0 ? 1 : 0;
- }
-
-
- /* Close the test file and exit */
- H5F_close (f);
- if (nerrors) {
- printf ("***** %d I-STORE TEST%s FAILED! *****\n",
- nerrors, 1==nerrors?"":"S");
- if (isatty (1)) {
- printf ("(Redirect output to a pager or a file to see "
- "debug output)\n");
- }
- exit (1);
- }
-
- printf ("All i-store tests passed.\n");
- exit (0);
+ /*
+ * By creating a group we cause the library to emit it's debugging
+ * diagnostic messages before we begin testing...
+ */
+ dir = H5G_create(f, "flushing_diagnostics", 0);
+ H5G_close(dir);
+ dir = NULL;
+
+ /*
+ * Creation test: Creates empty objects with various raw data sizes
+ * and alignments.
+ */
+ status = test_create(f, "create");
+ nerrors += status < 0 ? 1 : 0;
+
+ if (size_of_test & TEST_SMALL) {
+ status = test_extend(f, "extend", 10, 0, 0);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_extend(f, "extend", 10, 10, 0);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_extend(f, "extend", 10, 10, 10);
+ nerrors += status < 0 ? 1 : 0;
+ }
+ if (size_of_test & TEST_MEDIUM) {
+ status = test_extend(f, "extend", 10000, 0, 0);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_extend(f, "extend", 2500, 10, 0);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_extend(f, "extend", 10, 400, 10);
+ nerrors += status < 0 ? 1 : 0;
+ }
+ if (size_of_test & TEST_SMALL) {
+ status = test_sparse(f, "sparse", 100, 5, 0, 0);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_sparse(f, "sparse", 100, 3, 4, 0);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_sparse(f, "sparse", 100, 2, 3, 4);
+ nerrors += status < 0 ? 1 : 0;
+ }
+ if (size_of_test & TEST_MEDIUM) {
+ status = test_sparse(f, "sparse", 1000, 30, 0, 0);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_sparse(f, "sparse", 2000, 7, 3, 0);
+ nerrors += status < 0 ? 1 : 0;
+ status = test_sparse(f, "sparse", 2000, 4, 2, 3);
+ nerrors += status < 0 ? 1 : 0;
+ }
+ if (size_of_test & TEST_LARGE) {
+ status = test_sparse(f, "sparse", 800, 50, 50, 50);
+ nerrors += status < 0 ? 1 : 0;
+ }
+ /* Close the test file and exit */
+ H5F_close(f);
+ if (nerrors) {
+ printf("***** %d I-STORE TEST%s FAILED! *****\n",
+ nerrors, 1 == nerrors ? "" : "S");
+ if (isatty(1)) {
+ printf("(Redirect output to a pager or a file to see "
+ "debug output)\n");
+ }
+ exit(1);
+ }
+ printf("All i-store tests passed.\n");
+ exit(0);
}
diff --git a/test/testhdf5.c b/test/testhdf5.c
index 93e059a..b59c3ab 100644
--- a/test/testhdf5.c
+++ b/test/testhdf5.c
@@ -11,31 +11,31 @@
****************************************************************************/
#ifdef RCSID
-static char RcsId[] = "@(#)$Revision$";
+static char RcsId[] = "@(#)$Revision$";
#endif
/* $Id$ */
/*
FILE
- testhdf5.c - HDF5 testing framework main file.
+ testhdf5.c - HDF5 testing framework main file.
REMARKS
- General test wrapper for HDF5 base library test programs
+ General test wrapper for HDF5 base library test programs
DESIGN
- Each test function should be implemented as function having no
- parameters and returning void (i.e. no return value). They should be put
- into the list of InitTest() calls in main() below. Functions which depend
- on other functionality should be placed below the InitTest() call for the
- base functionality testing.
- Each test module should include testhdf5.h and define a unique set of
- names for test files they create.
+ Each test function should be implemented as function having no
+ parameters and returning void (i.e. no return value). They should be put
+ into the list of InitTest() calls in main() below. Functions which depend
+ on other functionality should be placed below the InitTest() call for the
+ base functionality testing.
+ Each test module should include testhdf5.h and define a unique set of
+ names for test files they create.
BUGS/LIMITATIONS
EXPORTED ROUTINES/VARIABLES:
- Two variables are exported: num_errs, and Verbosity.
+ Two variables are exported: num_errs, and Verbosity.
*/
@@ -49,35 +49,33 @@ static char RcsId[] = "@(#)$Revision$";
#define HDF5_TEST_MASTER
/* Internal Variables */
-static int Index = 0;
+static int Index = 0;
/* Global variables */
-int num_errs;
-int Verbosity;
+int num_errs;
+int Verbosity;
/* ANY new test needs to have a prototype in tproto.h */
#include <testhdf5.h>
-struct TestStruct
- {
- int NumErrors;
- char Description[64];
- int SkipFlag;
- char Name[16];
- VOID (*Call) (void);
- }
- Test[MAXNUMOFTESTS];
+struct TestStruct {
+ int NumErrors;
+ char Description[64];
+ int SkipFlag;
+ char Name[16];
+ VOID(*Call) (void);
+} Test[MAXNUMOFTESTS];
-static void InitTest(const char *TheName, VOID(*TheCall) (void), const char *TheDescr);
-static void usage(void);
+static void InitTest(const char *TheName, VOID(*TheCall) (void), const char *TheDescr);
+static void usage(void);
-static void InitTest(const char *TheName, VOID(*TheCall) (void), const char *TheDescr)
+static void
+InitTest(const char *TheName, VOID(*TheCall) (void), const char *TheDescr)
{
- if (Index >= MAXNUMOFTESTS)
- {
- print_func("Uh-oh, too many tests added, increase MAXNUMOFTEST!\n");
- exit(0);
- } /* end if */
+ if (Index >= MAXNUMOFTESTS) {
+ print_func("Uh-oh, too many tests added, increase MAXNUMOFTEST!\n");
+ exit(0);
+ } /* end if */
HDstrcpy(Test[Index].Description, TheDescr);
HDstrcpy(Test[Index].Name, TheName);
Test[Index].Call = TheCall;
@@ -86,9 +84,10 @@ static void InitTest(const char *TheName, VOID(*TheCall) (void), const char *The
Index++;
}
-static void usage(void)
+static void
+usage(void)
{
- intn i;
+ intn i;
print_func("Usage: testhdf5 [-v[erbose] (l[ow]|m[edium]|h[igh]|0-10)] \n");
print_func(" [-[e]x[clude] name+] \n");
@@ -114,32 +113,34 @@ static void usage(void)
for (i = 0; i < Index; i++)
print_func("%16s %s\n", Test[i].Name, Test[i].Description);
print_func("\n\n");
-} /* end usage() */
+} /* end usage() */
/*
* This routine is designed to provide equivalent functionality to 'printf'
* and allow easy replacement for environments which don't have stdin/stdout
* available. (i.e. Windows & the Mac)
*/
-int print_func(const char *format, ...)
+int
+print_func(const char *format,...)
{
- va_list arglist;
- int ret_value;
+ va_list arglist;
+ int ret_value;
va_start(arglist, format);
- ret_value=vprintf(format, arglist);
+ ret_value = vprintf(format, arglist);
va_end(arglist);
- return(ret_value);
+ return (ret_value);
}
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
- int CLLoop; /* Command Line Loop */
- int Loop, Loop1;
- int Summary = 0;
- int CleanUp = 1;
- int Cache = 1;
- uintn major, minor, release, patch;
+ int CLLoop; /* Command Line Loop */
+ int Loop, Loop1;
+ int Summary = 0;
+ int CleanUp = 1;
+ int Cache = 1;
+ uintn major, minor, release, patch;
#if defined __MWERKS__
argc = ccommand(&argv);
@@ -159,112 +160,97 @@ int main(int argc, char *argv[])
InitTest("stab", test_stab, "Symbol Tables");
InitTest("h5p", test_h5p, "Dataspaces");
- Verbosity = 4; /* Default Verbosity is Low */
+ Verbosity = 4; /* Default Verbosity is Low */
H5version(&major, &minor, &release, &patch);
print_func("\nFor help use: testhdf5 -help\n");
print_func("Linked with HDF %u.%u.%u%c\n\n", (unsigned) major,
- (unsigned) minor, (unsigned) release, 'a'+patch);
- for (CLLoop = 1; CLLoop < argc; CLLoop++)
- {
- if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-verbose") == 0) ||
- (HDstrcmp(argv[CLLoop], "-v") == 0)))
- {
- if (argv[CLLoop + 1][0] == 'l')
- Verbosity = 4;
- else if (argv[CLLoop + 1][0] == 'm')
- Verbosity = 6;
- else if (argv[CLLoop + 1][0] == 'h')
- Verbosity = 10;
- else
- Verbosity = atoi(argv[CLLoop + 1]);
- } /* end if */
- if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-summary") == 0) ||
- (HDstrcmp(argv[CLLoop], "-s") == 0)))
- Summary = 1;
-
- if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-help") == 0) ||
- (HDstrcmp(argv[CLLoop], "-h") == 0)))
- {
- usage();
- exit(0);
- }
-
- if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-cleanoff") == 0) ||
- (HDstrcmp(argv[CLLoop], "-c") == 0)))
- CleanUp = 0;
-
- if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-nocache") == 0) ||
- (HDstrcmp(argv[CLLoop], "-n") == 0)))
- Cache = 0;
-
- if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-exclude") == 0) ||
- (HDstrcmp(argv[CLLoop], "-x") == 0)))
- {
- Loop = CLLoop + 1;
- while ((Loop < argc) && (argv[Loop][0] != '-'))
- {
- for (Loop1 = 0; Loop1 < Index; Loop1++)
- if (HDstrcmp(argv[Loop], Test[Loop1].Name) == 0)
- Test[Loop1].SkipFlag = 1;
- Loop++;
- } /* end while */
- } /* end if */
- if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-begin") == 0) ||
- (HDstrcmp(argv[CLLoop], "-b") == 0)))
- {
- Loop = CLLoop + 1;
- while ((Loop < argc) && (argv[Loop][0] != '-'))
- {
- for (Loop1 = 0; Loop1 < Index; Loop1++)
- {
- if (HDstrcmp(argv[Loop], Test[Loop1].Name) != 0)
- Test[Loop1].SkipFlag = 1;
- if (HDstrcmp(argv[Loop], Test[Loop1].Name) == 0)
- Loop1 = Index;
- } /* end for */
- Loop++;
- } /* end while */
- } /* end if */
- if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-only") == 0) ||
- (HDstrcmp(argv[CLLoop], "-o") == 0)))
- {
- for (Loop = 0; Loop < Index; Loop++)
- Test[Loop].SkipFlag = 1;
- Loop = CLLoop + 1;
- while ((Loop < argc) && (argv[Loop][0] != '-'))
- {
- for (Loop1 = 0; Loop1 < Index; Loop1++)
- if (HDstrcmp(argv[Loop], Test[Loop1].Name) == 0)
- Test[Loop1].SkipFlag = 0;
- Loop++;
- } /* end while */
- } /* end if */
- } /* end for */
+ (unsigned) minor, (unsigned) release, 'a' + patch);
+ for (CLLoop = 1; CLLoop < argc; CLLoop++) {
+ if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-verbose") == 0) ||
+ (HDstrcmp(argv[CLLoop], "-v") == 0))) {
+ if (argv[CLLoop + 1][0] == 'l')
+ Verbosity = 4;
+ else if (argv[CLLoop + 1][0] == 'm')
+ Verbosity = 6;
+ else if (argv[CLLoop + 1][0] == 'h')
+ Verbosity = 10;
+ else
+ Verbosity = atoi(argv[CLLoop + 1]);
+ } /* end if */
+ if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-summary") == 0) ||
+ (HDstrcmp(argv[CLLoop], "-s") == 0)))
+ Summary = 1;
+
+ if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-help") == 0) ||
+ (HDstrcmp(argv[CLLoop], "-h") == 0))) {
+ usage();
+ exit(0);
+ }
+ if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-cleanoff") == 0) ||
+ (HDstrcmp(argv[CLLoop], "-c") == 0)))
+ CleanUp = 0;
+
+ if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-nocache") == 0) ||
+ (HDstrcmp(argv[CLLoop], "-n") == 0)))
+ Cache = 0;
+
+ if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-exclude") == 0) ||
+ (HDstrcmp(argv[CLLoop], "-x") == 0))) {
+ Loop = CLLoop + 1;
+ while ((Loop < argc) && (argv[Loop][0] != '-')) {
+ for (Loop1 = 0; Loop1 < Index; Loop1++)
+ if (HDstrcmp(argv[Loop], Test[Loop1].Name) == 0)
+ Test[Loop1].SkipFlag = 1;
+ Loop++;
+ } /* end while */
+ } /* end if */
+ if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-begin") == 0) ||
+ (HDstrcmp(argv[CLLoop], "-b") == 0))) {
+ Loop = CLLoop + 1;
+ while ((Loop < argc) && (argv[Loop][0] != '-')) {
+ for (Loop1 = 0; Loop1 < Index; Loop1++) {
+ if (HDstrcmp(argv[Loop], Test[Loop1].Name) != 0)
+ Test[Loop1].SkipFlag = 1;
+ if (HDstrcmp(argv[Loop], Test[Loop1].Name) == 0)
+ Loop1 = Index;
+ } /* end for */
+ Loop++;
+ } /* end while */
+ } /* end if */
+ if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-only") == 0) ||
+ (HDstrcmp(argv[CLLoop], "-o") == 0))) {
+ for (Loop = 0; Loop < Index; Loop++)
+ Test[Loop].SkipFlag = 1;
+ Loop = CLLoop + 1;
+ while ((Loop < argc) && (argv[Loop][0] != '-')) {
+ for (Loop1 = 0; Loop1 < Index; Loop1++)
+ if (HDstrcmp(argv[Loop], Test[Loop1].Name) == 0)
+ Test[Loop1].SkipFlag = 0;
+ Loop++;
+ } /* end while */
+ } /* end if */
+ } /* end for */
#ifdef NOT_YET
- if(Cache) /* turn on caching, unless we were instucted not to */
- Hcache(CACHE_ALL_FILES,TRUE);
+ if (Cache) /* turn on caching, unless we were instucted not to */
+ Hcache(CACHE_ALL_FILES, TRUE);
#endif /* NOT_YET */
- for (Loop = 0; Loop < Index; Loop++)
- {
- if (Test[Loop].SkipFlag)
- {
- MESSAGE(2, ("Skipping -- %s \n", Test[Loop].Description));
- }
- else
- {
- MESSAGE(2, ("Testing -- %s (%s) \n", Test[Loop].Description,
- Test[Loop].Name));
- MESSAGE(5, ("===============================================\n"));
- Test[Loop].NumErrors = num_errs;
- (*Test[Loop].Call) ();
- Test[Loop].NumErrors = num_errs - Test[Loop].NumErrors;
- MESSAGE(5, ("===============================================\n"));
- MESSAGE(5, ("There were %d errors detected.\n\n", (int) Test[Loop].NumErrors));
- } /* end else */
- } /* end for */
+ for (Loop = 0; Loop < Index; Loop++) {
+ if (Test[Loop].SkipFlag) {
+ MESSAGE(2, ("Skipping -- %s \n", Test[Loop].Description));
+ } else {
+ MESSAGE(2, ("Testing -- %s (%s) \n", Test[Loop].Description,
+ Test[Loop].Name));
+ MESSAGE(5, ("===============================================\n"));
+ Test[Loop].NumErrors = num_errs;
+ (*Test[Loop].Call) ();
+ Test[Loop].NumErrors = num_errs - Test[Loop].NumErrors;
+ MESSAGE(5, ("===============================================\n"));
+ MESSAGE(5, ("There were %d errors detected.\n\n", (int) Test[Loop].NumErrors));
+ } /* end else */
+ } /* end for */
MESSAGE(2, ("\n\n"))
if (num_errs)
@@ -272,33 +258,29 @@ int main(int argc, char *argv[])
else
print_func("All tests were successful. \n\n");
- if (Summary)
- {
- print_func("Summary of Test Results:\n");
- print_func("Name of Test Errors Description of Test\n");
- print_func("---------------- ------ --------------------------------------\n");
-
- for (Loop = 0; Loop < Index; Loop++)
- {
- if (Test[Loop].NumErrors == -1)
- print_func("%16s %6s %s\n", Test[Loop].Name, "N/A", Test[Loop].Description);
- else
- print_func("%16s %6d %s\n", Test[Loop].Name, (int) Test[Loop].NumErrors,
- Test[Loop].Description);
- } /* end for */
- print_func("\n\n");
- } /* end if */
+ if (Summary) {
+ print_func("Summary of Test Results:\n");
+ print_func("Name of Test Errors Description of Test\n");
+ print_func("---------------- ------ --------------------------------------\n");
- if (CleanUp)
- {
- MESSAGE(2, ("\nCleaning Up...\n\n"));
+ for (Loop = 0; Loop < Index; Loop++) {
+ if (Test[Loop].NumErrors == -1)
+ print_func("%16s %6s %s\n", Test[Loop].Name, "N/A", Test[Loop].Description);
+ else
+ print_func("%16s %6d %s\n", Test[Loop].Name, (int) Test[Loop].NumErrors,
+ Test[Loop].Description);
+ } /* end for */
+ print_func("\n\n");
+ } /* end if */
+ if (CleanUp) {
+ MESSAGE(2, ("\nCleaning Up...\n\n"));
#if !(defined DOS386 | defined WIN386)
- system("rm -f *.h5 *.tmp");
-#else /* OLD_WAY */
- remove("*.h5");
- remove("*.tmp");
-#endif /* OLD_WAY */
- } /* end if */
+ system("rm -f *.h5 *.tmp");
+#else /* OLD_WAY */
+ remove("*.h5");
+ remove("*.tmp");
+#endif /* OLD_WAY */
+ } /* end if */
exit(0);
return (0);
-} /* end main() */
+} /* end main() */
diff --git a/test/testhdf5.h b/test/testhdf5.h
index 27b9e19..d13f08a 100644
--- a/test/testhdf5.h
+++ b/test/testhdf5.h
@@ -26,8 +26,8 @@
#include <H5private.h>
#include <H5Eprivate.h>
-extern int num_errs;
-extern int Verbosity;
+extern int num_errs;
+extern int Verbosity;
/* Use %ld to print the value because long should cover most cases. */
/* Used to make certain a return value _is_not_ a value */
@@ -36,30 +36,30 @@ do {if (Verbosity>9) print_func(" Call to routine: %15s at line %4d in %s retu
if(ret == val) {print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d in %s\n", where, (long)ret, (int)__LINE__,__FILE__); num_errs++;H5Eprint (H5E_thrdid_g, stdout);} \
} while(0)
-#define CHECK_I(ret,where) { \
- if (Verbosity>9) { \
+#define CHECK_I(ret,where) { \
+ if (Verbosity>9) { \
print_func(" Call to routine: %15s at line %4d in %s returned %ld\n", \
- (where), (int)__LINE__, __FILE__, (long)(ret)); \
- } \
- if ((ret)<0) { \
+ (where), (int)__LINE__, __FILE__, (long)(ret)); \
+ } \
+ if ((ret)<0) { \
print_func ("*** UNEXPECTED RETURN from %s is %ld line %4d in %s\n", \
- (where), (long)(ret), (int)__LINE__, __FILE__); \
- H5Eprint (H5E_thrdid_g, stdout); \
- num_errs++; \
- } \
+ (where), (long)(ret), (int)__LINE__, __FILE__); \
+ H5Eprint (H5E_thrdid_g, stdout); \
+ num_errs++; \
+ } \
}
-
-#define CHECK_PTR(ret,where) { \
- if (Verbosity>9) { \
+
+#define CHECK_PTR(ret,where) { \
+ if (Verbosity>9) { \
print_func(" Call to routine: %15s at line %4d in %s returned %p\n", \
- (where), (int)__LINE__, __FILE__, (ret)); \
- } \
- if (!(ret)) { \
+ (where), (int)__LINE__, __FILE__, (ret)); \
+ } \
+ if (!(ret)) { \
print_func ("*** UNEXPECTED RETURN from %s is NULL line %4d in %s\n", \
- (where), (int)__LINE__, __FILE__); \
- H5Eprint (H5E_thrdid_g, stdout); \
- num_errs++; \
- } \
+ (where), (int)__LINE__, __FILE__); \
+ H5Eprint (H5E_thrdid_g, stdout); \
+ num_errs++; \
+ } \
}
/* Used to make certain a return value _is_ a value */
@@ -80,35 +80,34 @@ if(ret == FAIL) {print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d in
#define MESSAGE(V,A) {if (Verbosity>(V)) print_func A;}
/* definitions for command strings */
-#define VERBOSITY_STR "Verbosity"
-#define SKIP_STR "Skip"
-#define TEST_STR "Test"
-#define CLEAN_STR "Cleanup"
+#define VERBOSITY_STR "Verbosity"
+#define SKIP_STR "Skip"
+#define TEST_STR "Test"
+#define CLEAN_STR "Cleanup"
/* System command to use for Cleanup */
#ifdef VMS
-#define CLEAN_CMD "delete *.hdf;*"
+#define CLEAN_CMD "delete *.hdf;*"
#else
# ifdef WIN32
-# define CLEAN_CMD "del *.hdf"
+# define CLEAN_CMD "del *.hdf"
# else
/* default is Unix */
-# define CLEAN_CMD "rm -f *.hdf"
-# endif /* WIN32 */
+# define CLEAN_CMD "rm -f *.hdf"
+# endif /* WIN32 */
#endif /*VMS */
/* Prototypes for the support routines */
-int print_func(const char *, ...);
+int print_func(const char *,...);
/* Prototypes for the test routines */
-void test_metadata(void);
-void test_file(void);
-void test_heap (void);
-void test_ohdr (void);
-void test_stab (void);
-void test_h5t (void);
-void test_h5p (void);
-void test_h5d (void);
+void test_metadata(void);
+void test_file(void);
+void test_heap(void);
+void test_ohdr(void);
+void test_stab(void);
+void test_h5t(void);
+void test_h5p(void);
+void test_h5d(void);
#endif /* HDF5TEST_H */
-
diff --git a/test/tfile.c b/test/tfile.c
index b72e037..ffbe172 100644
--- a/test/tfile.c
+++ b/test/tfile.c
@@ -11,7 +11,7 @@
****************************************************************************/
#ifdef RCSID
-static char RcsId[] = "$Revision$";
+static char RcsId[] = "$Revision$";
#endif
/* $Id$ */
@@ -34,22 +34,22 @@ static char RcsId[] = "$Revision$";
#define F1_USERBLOCK_SIZE 0
#define F1_OFFSET_SIZE 4
#define F1_LENGTH_SIZE 4
-#define F1_SYM_LEAF_K 4
-#define F1_SYM_INTERN_K 16
+#define F1_SYM_LEAF_K 4
+#define F1_SYM_INTERN_K 16
#define FILE1 "tfile1.h5"
#define F2_USERBLOCK_SIZE 512
#define F2_OFFSET_SIZE 8
#define F2_LENGTH_SIZE 8
-#define F2_SYM_LEAF_K 8
-#define F2_SYM_INTERN_K 32
+#define F2_SYM_LEAF_K 8
+#define F2_SYM_INTERN_K 32
#define FILE2 "tfile2.h5"
#define F3_USERBLOCK_SIZE 0
#define F3_OFFSET_SIZE F2_OFFSET_SIZE
#define F3_LENGTH_SIZE F2_LENGTH_SIZE
-#define F3_SYM_LEAF_K F2_SYM_LEAF_K
-#define F3_SYM_INTERN_K F2_SYM_INTERN_K
+#define F3_SYM_LEAF_K F2_SYM_LEAF_K
+#define F3_SYM_INTERN_K F2_SYM_INTERN_K
#define FILE3 "tfile3.h5"
/****************************************************************
@@ -57,218 +57,218 @@ static char RcsId[] = "$Revision$";
** test_file_create(): Low-level file creation I/O test routine.
**
****************************************************************/
-static void test_file_create(void)
+static void
+test_file_create(void)
{
- hid_t fid1,fid2,fid3; /* HDF5 File IDs */
- hid_t tmpl1,tmpl2; /* File creation templates */
- size_t parm; /* File-creation parameters */
- size_t parm2; /* File-creation parameters */
- int iparm, iparm2;
- herr_t ret; /* Generic return value */
+ hid_t fid1, fid2, fid3; /* HDF5 File IDs */
+ hid_t tmpl1, tmpl2; /* File creation templates */
+ size_t parm; /* File-creation parameters */
+ size_t parm2; /* File-creation parameters */
+ int iparm, iparm2;
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Low-Level File Creation I/O\n"));
/* Create first file */
- fid1=H5Fcreate(FILE1,H5ACC_OVERWRITE,0,0);
- CHECK(fid1,FAIL,"H5Fcreate");
+ fid1 = H5Fcreate(FILE1, H5ACC_OVERWRITE, 0, 0);
+ CHECK(fid1, FAIL, "H5Fcreate");
/* Try to create first file again (should fail) */
- fid2=H5Fcreate(FILE1,H5ACC_OVERWRITE,0,0);
- VERIFY(fid2,FAIL,"H5Fcreate");
+ fid2 = H5Fcreate(FILE1, H5ACC_OVERWRITE, 0, 0);
+ VERIFY(fid2, FAIL, "H5Fcreate");
/* Get the file-creation template */
- tmpl1 = H5Fget_create_template (fid1);
- CHECK(tmpl1,FAIL,"H5Fget_create_template");
+ tmpl1 = H5Fget_create_template(fid1);
+ CHECK(tmpl1, FAIL, "H5Fget_create_template");
/* Get the file-creation parameters */
- ret = H5Cget_userblock (tmpl1, &parm);
- CHECK(ret,FAIL,"H5Cget_userblock");
- VERIFY(parm,F1_USERBLOCK_SIZE,"H5Cget_userblock");
+ ret = H5Cget_userblock(tmpl1, &parm);
+ CHECK(ret, FAIL, "H5Cget_userblock");
+ VERIFY(parm, F1_USERBLOCK_SIZE, "H5Cget_userblock");
- ret = H5Cget_sizes (tmpl1, &parm, &parm2);
- CHECK(ret,FAIL,"H5Cget_sizes");
- VERIFY (parm, F1_OFFSET_SIZE, "H5Cget_sizes");
- VERIFY(parm2,F1_LENGTH_SIZE,"H5Cget_sizes");
+ ret = H5Cget_sizes(tmpl1, &parm, &parm2);
+ CHECK(ret, FAIL, "H5Cget_sizes");
+ VERIFY(parm, F1_OFFSET_SIZE, "H5Cget_sizes");
+ VERIFY(parm2, F1_LENGTH_SIZE, "H5Cget_sizes");
- ret = H5Cget_sym_k (tmpl1, &iparm, &iparm2);
- CHECK(ret,FAIL,"H5Cget_sym_k");
- VERIFY (iparm, F1_SYM_INTERN_K, "H5Cget_sym_k");
- VERIFY(iparm2,F1_SYM_LEAF_K,"H5Cget_sym_k");
+ ret = H5Cget_sym_k(tmpl1, &iparm, &iparm2);
+ CHECK(ret, FAIL, "H5Cget_sym_k");
+ VERIFY(iparm, F1_SYM_INTERN_K, "H5Cget_sym_k");
+ VERIFY(iparm2, F1_SYM_LEAF_K, "H5Cget_sym_k");
/* Release file-creation template */
- ret=H5Mclose(tmpl1);
- CHECK(ret,FAIL,"H5Mrelease");
-
+ ret = H5Mclose(tmpl1);
+ CHECK(ret, FAIL, "H5Mrelease");
+
/* Double-check that the atom has been vaporized */
- ret=H5Mclose(tmpl1);
- VERIFY(ret,FAIL,"H5Mrelease");
+ ret = H5Mclose(tmpl1);
+ VERIFY(ret, FAIL, "H5Mrelease");
/* Create a new file with a non-standard file-creation template */
- tmpl1 = H5Ccreate (H5C_FILE_CREATE);
- CHECK(tmpl1,FAIL,"H5Cnew");
+ tmpl1 = H5Ccreate(H5C_FILE_CREATE);
+ CHECK(tmpl1, FAIL, "H5Cnew");
/* Set the new file-creation parameters */
- ret = H5Cset_userblock (tmpl1, F2_USERBLOCK_SIZE);
- CHECK(ret,FAIL,"H5Cset_userblock");
+ ret = H5Cset_userblock(tmpl1, F2_USERBLOCK_SIZE);
+ CHECK(ret, FAIL, "H5Cset_userblock");
- ret = H5Cset_sizes (tmpl1, F2_OFFSET_SIZE, F2_LENGTH_SIZE);
- CHECK(ret,FAIL,"H5Cset_sizes");
+ ret = H5Cset_sizes(tmpl1, F2_OFFSET_SIZE, F2_LENGTH_SIZE);
+ CHECK(ret, FAIL, "H5Cset_sizes");
- ret = H5Cset_sym_k (tmpl1, F2_SYM_INTERN_K, F2_SYM_LEAF_K);
- CHECK(ret,FAIL,"H5Cset_sym_k");
+ ret = H5Cset_sym_k(tmpl1, F2_SYM_INTERN_K, F2_SYM_LEAF_K);
+ CHECK(ret, FAIL, "H5Cset_sym_k");
/*
* Try to create second file, with non-standard file-creation template
* params.
*/
- fid2=H5Fcreate(FILE2,H5ACC_OVERWRITE,tmpl1,0);
- CHECK(fid2,FAIL,"H5Fcreate");
+ fid2 = H5Fcreate(FILE2, H5ACC_OVERWRITE, tmpl1, 0);
+ CHECK(fid2, FAIL, "H5Fcreate");
/* Release file-creation template */
- ret=H5Mclose(tmpl1);
- CHECK(ret,FAIL,"H5Mrelease");
-
+ ret = H5Mclose(tmpl1);
+ CHECK(ret, FAIL, "H5Mrelease");
+
/* Get the file-creation template */
- tmpl1=H5Fget_create_template(fid2);
- CHECK(tmpl1,FAIL,"H5Fget_create_template");
+ tmpl1 = H5Fget_create_template(fid2);
+ CHECK(tmpl1, FAIL, "H5Fget_create_template");
/* Get the file-creation parameters */
- ret = H5Cget_userblock (tmpl1, &parm);
- CHECK(ret,FAIL,"H5Cget_userblock");
- VERIFY(parm,F2_USERBLOCK_SIZE,"H5Cget_userblock");
+ ret = H5Cget_userblock(tmpl1, &parm);
+ CHECK(ret, FAIL, "H5Cget_userblock");
+ VERIFY(parm, F2_USERBLOCK_SIZE, "H5Cget_userblock");
- ret = H5Cget_sizes (tmpl1, &parm, &parm2);
- CHECK(ret,FAIL,"H5Cget_sizes");
- VERIFY (parm, F2_OFFSET_SIZE, "H5Cget_sizes");
- VERIFY(parm2,F2_LENGTH_SIZE,"H5Cget_sizes");
+ ret = H5Cget_sizes(tmpl1, &parm, &parm2);
+ CHECK(ret, FAIL, "H5Cget_sizes");
+ VERIFY(parm, F2_OFFSET_SIZE, "H5Cget_sizes");
+ VERIFY(parm2, F2_LENGTH_SIZE, "H5Cget_sizes");
- ret = H5Cget_sym_k (tmpl1, &iparm, &iparm2);
- CHECK(ret,FAIL,"H5Cget_sym_k");
- VERIFY (iparm, F2_SYM_INTERN_K, "H5Cget_sym_k");
- VERIFY(iparm2,F2_SYM_LEAF_K,"H5Cget_sym_k");
+ ret = H5Cget_sym_k(tmpl1, &iparm, &iparm2);
+ CHECK(ret, FAIL, "H5Cget_sym_k");
+ VERIFY(iparm, F2_SYM_INTERN_K, "H5Cget_sym_k");
+ VERIFY(iparm2, F2_SYM_LEAF_K, "H5Cget_sym_k");
/* Clone the file-creation template */
- tmpl2=H5Mcopy(tmpl1);
- CHECK(tmpl2,FAIL,"H5Mcopy");
+ tmpl2 = H5Mcopy(tmpl1);
+ CHECK(tmpl2, FAIL, "H5Mcopy");
/* Release file-creation template */
- ret=H5Mclose(tmpl1);
- CHECK(ret,FAIL,"H5Mrelease");
+ ret = H5Mclose(tmpl1);
+ CHECK(ret, FAIL, "H5Mrelease");
/* Set the new file-creation parameter */
- ret = H5Cset_userblock (tmpl2, F3_USERBLOCK_SIZE);
- CHECK(ret,FAIL,"H5Cset_userblock");
+ ret = H5Cset_userblock(tmpl2, F3_USERBLOCK_SIZE);
+ CHECK(ret, FAIL, "H5Cset_userblock");
/*
* Try to create second file, with non-standard file-creation template
* params
*/
- fid3=H5Fcreate(FILE3,H5ACC_OVERWRITE,tmpl2,0);
- CHECK(fid3,FAIL,"H5Fcreate");
+ fid3 = H5Fcreate(FILE3, H5ACC_OVERWRITE, tmpl2, 0);
+ CHECK(fid3, FAIL, "H5Fcreate");
/* Release file-creation template */
- ret=H5Mclose(tmpl2);
- CHECK(ret,FAIL,"H5Mrelease");
+ ret = H5Mclose(tmpl2);
+ CHECK(ret, FAIL, "H5Mrelease");
/* Get the file-creation template */
- tmpl1=H5Fget_create_template(fid3);
- CHECK(tmpl1,FAIL,"H5Fget_create_template");
+ tmpl1 = H5Fget_create_template(fid3);
+ CHECK(tmpl1, FAIL, "H5Fget_create_template");
/* Get the file-creation parameters */
- ret = H5Cget_userblock (tmpl1, &parm);
- CHECK(ret,FAIL,"H5Cget_userblock");
- VERIFY(parm,F3_USERBLOCK_SIZE,"H5Cget_userblock");
+ ret = H5Cget_userblock(tmpl1, &parm);
+ CHECK(ret, FAIL, "H5Cget_userblock");
+ VERIFY(parm, F3_USERBLOCK_SIZE, "H5Cget_userblock");
- ret = H5Cget_sizes (tmpl1, &parm, &parm2);
- CHECK(ret,FAIL,"H5Cget_sizes");
- VERIFY (parm, F3_OFFSET_SIZE, "H5Cget_sizes");
- VERIFY(parm2,F3_LENGTH_SIZE,"H5Cget_sizes");
+ ret = H5Cget_sizes(tmpl1, &parm, &parm2);
+ CHECK(ret, FAIL, "H5Cget_sizes");
+ VERIFY(parm, F3_OFFSET_SIZE, "H5Cget_sizes");
+ VERIFY(parm2, F3_LENGTH_SIZE, "H5Cget_sizes");
- ret = H5Cget_sym_k (tmpl1, &iparm, &iparm2);
- CHECK(ret,FAIL,"H5Cget_sym_k");
- VERIFY (iparm, F3_SYM_INTERN_K, "H5Cget_sym_k");
- VERIFY(iparm2,F3_SYM_LEAF_K,"H5Cget_sym_k");
+ ret = H5Cget_sym_k(tmpl1, &iparm, &iparm2);
+ CHECK(ret, FAIL, "H5Cget_sym_k");
+ VERIFY(iparm, F3_SYM_INTERN_K, "H5Cget_sym_k");
+ VERIFY(iparm2, F3_SYM_LEAF_K, "H5Cget_sym_k");
/* Release file-creation template */
- ret=H5Mclose(tmpl1);
- CHECK(ret,FAIL,"H5Mrelease");
+ ret = H5Mclose(tmpl1);
+ CHECK(ret, FAIL, "H5Mrelease");
/* Close first file */
- ret=H5Fclose(fid1);
- CHECK(ret,FAIL,"H5Fclose");
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
/* Close second file */
- ret=H5Fclose(fid2);
- CHECK(ret,FAIL,"H5Fclose");
+ ret = H5Fclose(fid2);
+ CHECK(ret, FAIL, "H5Fclose");
/* Close third file */
- ret=H5Fclose(fid3);
- CHECK(ret,FAIL,"H5Fclose");
-} /* test_file_create() */
-
+ ret = H5Fclose(fid3);
+ CHECK(ret, FAIL, "H5Fclose");
+} /* test_file_create() */
/****************************************************************
**
** test_file_open(): Low-level file open I/O test routine.
**
****************************************************************/
-static void test_file_open(void)
+static void
+test_file_open(void)
{
- hid_t fid1; /* HDF5 File IDs */
- hid_t tmpl1; /* File creation templates */
- size_t parm; /* File-creation parameters */
- size_t parm2; /* File-creation parameters */
- int iparm, iparm2;
- herr_t ret; /* Generic return value */
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t tmpl1; /* File creation templates */
+ size_t parm; /* File-creation parameters */
+ size_t parm2; /* File-creation parameters */
+ int iparm, iparm2;
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Low-Level File Opening I/O\n"));
/* Open first file */
- fid1=H5Fopen(FILE2,H5ACC_WRITE,0);
- CHECK(fid1,FAIL,"H5Fopen");
+ fid1 = H5Fopen(FILE2, H5ACC_WRITE, 0);
+ CHECK(fid1, FAIL, "H5Fopen");
/* Get the file-creation template */
- tmpl1=H5Fget_create_template(fid1);
- CHECK(tmpl1,FAIL,"H5Fget_create_template");
+ tmpl1 = H5Fget_create_template(fid1);
+ CHECK(tmpl1, FAIL, "H5Fget_create_template");
/* Get the file-creation parameters */
- ret = H5Cget_userblock (tmpl1, &parm);
- CHECK(ret,FAIL,"H5Cget_userblock");
- VERIFY(parm,F2_USERBLOCK_SIZE,"H5Cget_userblock");
+ ret = H5Cget_userblock(tmpl1, &parm);
+ CHECK(ret, FAIL, "H5Cget_userblock");
+ VERIFY(parm, F2_USERBLOCK_SIZE, "H5Cget_userblock");
- ret = H5Cget_sizes (tmpl1, &parm, &parm2);
- CHECK(ret,FAIL,"H5Cget_sizes");
- VERIFY(parm,F2_OFFSET_SIZE,"H5Cget_sizes");
- VERIFY(parm2,F2_LENGTH_SIZE,"H5Cget_sizes");
+ ret = H5Cget_sizes(tmpl1, &parm, &parm2);
+ CHECK(ret, FAIL, "H5Cget_sizes");
+ VERIFY(parm, F2_OFFSET_SIZE, "H5Cget_sizes");
+ VERIFY(parm2, F2_LENGTH_SIZE, "H5Cget_sizes");
- ret = H5Cget_sym_k (tmpl1, &iparm, &iparm2);
- CHECK(ret,FAIL,"H5Cget_sym_k");
- VERIFY (iparm, F2_SYM_INTERN_K, "H5Cget_sym_k");
- VERIFY(iparm2,F2_SYM_LEAF_K,"H5Cget_sym_k");
+ ret = H5Cget_sym_k(tmpl1, &iparm, &iparm2);
+ CHECK(ret, FAIL, "H5Cget_sym_k");
+ VERIFY(iparm, F2_SYM_INTERN_K, "H5Cget_sym_k");
+ VERIFY(iparm2, F2_SYM_LEAF_K, "H5Cget_sym_k");
/* Release file-creation template */
- ret=H5Mclose(tmpl1);
- CHECK(ret,FAIL,"H5Mrelease");
-
- /* Close first file */
- ret=H5Fclose(fid1);
- CHECK(ret,FAIL,"H5Fclose");
-} /* test_file_open() */
+ ret = H5Mclose(tmpl1);
+ CHECK(ret, FAIL, "H5Mrelease");
+ /* Close first file */
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+} /* test_file_open() */
/****************************************************************
**
** test_file(): Main low-level file I/O test routine.
**
****************************************************************/
-void test_file(void)
+void
+test_file(void)
{
/* Output message about test being performed */
MESSAGE(5, ("Testing Low-Level File I/O\n"));
- test_file_create(); /* Test file creation (also creation templates) */
- test_file_open(); /* Test file opening */
-} /* test_file() */
-
+ test_file_create(); /* Test file creation (also creation templates) */
+ test_file_open(); /* Test file opening */
+} /* test_file() */
diff --git a/test/th5p.c b/test/th5p.c
index eb8528b..78ec4a9 100644
--- a/test/th5p.c
+++ b/test/th5p.c
@@ -11,7 +11,7 @@
****************************************************************************/
#ifdef RCSID
-static char RcsId[] = "$Revision$";
+static char RcsId[] = "$Revision$";
#endif
/* $Id$ */
@@ -53,82 +53,83 @@ static char RcsId[] = "$Revision$";
** test_h5p_basic(): Test basic H5P (dataspace) code.
**
****************************************************************/
-static void test_h5p_basic(void)
+static void
+test_h5p_basic(void)
{
- hid_t fid1; /* HDF5 File IDs */
- hid_t sid1,sid2; /* Dataspace ID */
- uint32 rank; /* Logical rank of dataspace */
- size_t dims1[]={SPACE1_DIM1,SPACE1_DIM2,SPACE1_DIM3}, /* dataspace dim sizes */
- dims2[]={SPACE2_DIM1,SPACE2_DIM2,SPACE2_DIM3,SPACE2_DIM4},
- tdims[4]; /* Dimension array to test with */
- uintn n; /* number of dataspace elements */
- herr_t ret; /* Generic return value */
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t sid1, sid2; /* Dataspace ID */
+ uint32 rank; /* Logical rank of dataspace */
+ size_t dims1[] =
+ {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}, /* dataspace dim sizes */
+ dims2[] =
+ {SPACE2_DIM1, SPACE2_DIM2, SPACE2_DIM3, SPACE2_DIM4}, tdims[4]; /* Dimension array to test with */
+ uintn n; /* number of dataspace elements */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Datatype Manipulation\n"));
/* Create file */
- fid1=H5Fcreate(FILE,H5ACC_OVERWRITE,0,0);
- CHECK(fid1,FAIL,"H5Fcreate");
-
- sid1=H5Pcreate (H5P_SIMPLE);
- CHECK(sid1,FAIL,"H5Mcreate");
-
- ret=H5Pset_space(sid1,SPACE1_RANK,dims1);
- CHECK(ret,FAIL,"H5Pset_space");
-
- n=H5Pget_npoints(sid1);
- CHECK(n,UFAIL,"H5Pnelem");
- VERIFY(n,SPACE1_DIM1*SPACE1_DIM2*SPACE1_DIM3,"H5Pnelem");
-
- rank=H5Pget_ndims(sid1);
- CHECK(rank,UFAIL,"H5Pget_lrank");
- VERIFY(rank,SPACE1_RANK,"H5Pget_lrank");
-
- ret=H5Pget_dims(sid1,tdims);
- CHECK(ret,FAIL,"H5Pget_ldims");
- VERIFY(HDmemcmp(tdims,dims1,SPACE1_RANK*sizeof(uint32)),0,"H5Pget_ldims");
-
- sid2=H5Pcreate(H5P_SIMPLE);
- CHECK(sid2,FAIL,"H5Mcreate");
-
- ret=H5Pset_space(sid2,SPACE2_RANK,dims2);
- CHECK(ret,FAIL,"H5Pset_space");
-
- n=H5Pget_npoints(sid2);
- CHECK(n,UFAIL,"H5Pnelem");
- VERIFY(n,SPACE2_DIM1*SPACE2_DIM2*SPACE2_DIM3*SPACE2_DIM4,"H5Pnelem");
-
- rank=H5Pget_ndims(sid2);
- CHECK(rank,UFAIL,"H5Pget_lrank");
- VERIFY(rank,SPACE2_RANK,"H5Pget_lrank");
-
- ret=H5Pget_dims(sid2,tdims);
- CHECK(ret,FAIL,"H5Pget_ldims");
- VERIFY(HDmemcmp(tdims,dims2,SPACE2_RANK*sizeof(uint32)),0,"H5Pget_ldims");
-
- ret=H5Mclose(sid1);
- CHECK(ret,FAIL,"H5Mrelease");
-
- ret=H5Mclose(sid2);
- CHECK(ret,FAIL,"H5Mrelease");
-
- /* Close first file */
- ret=H5Fclose(fid1);
- CHECK(ret,FAIL,"H5Fclose");
-} /* test_h5p_basic() */
+ fid1 = H5Fcreate(FILE, H5ACC_OVERWRITE, 0, 0);
+ CHECK(fid1, FAIL, "H5Fcreate");
+
+ sid1 = H5Pcreate(H5P_SIMPLE);
+ CHECK(sid1, FAIL, "H5Mcreate");
+
+ ret = H5Pset_space(sid1, SPACE1_RANK, dims1);
+ CHECK(ret, FAIL, "H5Pset_space");
+
+ n = H5Pget_npoints(sid1);
+ CHECK(n, UFAIL, "H5Pnelem");
+ VERIFY(n, SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3, "H5Pnelem");
+
+ rank = H5Pget_ndims(sid1);
+ CHECK(rank, UFAIL, "H5Pget_lrank");
+ VERIFY(rank, SPACE1_RANK, "H5Pget_lrank");
+
+ ret = H5Pget_dims(sid1, tdims);
+ CHECK(ret, FAIL, "H5Pget_ldims");
+ VERIFY(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(uint32)), 0, "H5Pget_ldims");
+
+ sid2 = H5Pcreate(H5P_SIMPLE);
+ CHECK(sid2, FAIL, "H5Mcreate");
+
+ ret = H5Pset_space(sid2, SPACE2_RANK, dims2);
+ CHECK(ret, FAIL, "H5Pset_space");
+ n = H5Pget_npoints(sid2);
+ CHECK(n, UFAIL, "H5Pnelem");
+ VERIFY(n, SPACE2_DIM1 * SPACE2_DIM2 * SPACE2_DIM3 * SPACE2_DIM4, "H5Pnelem");
+
+ rank = H5Pget_ndims(sid2);
+ CHECK(rank, UFAIL, "H5Pget_lrank");
+ VERIFY(rank, SPACE2_RANK, "H5Pget_lrank");
+
+ ret = H5Pget_dims(sid2, tdims);
+ CHECK(ret, FAIL, "H5Pget_ldims");
+ VERIFY(HDmemcmp(tdims, dims2, SPACE2_RANK * sizeof(uint32)), 0, "H5Pget_ldims");
+
+ ret = H5Mclose(sid1);
+ CHECK(ret, FAIL, "H5Mrelease");
+
+ ret = H5Mclose(sid2);
+ CHECK(ret, FAIL, "H5Mrelease");
+
+ /* Close first file */
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+} /* test_h5p_basic() */
/****************************************************************
**
** test_h5p(): Main H5P (dataspace) testing routine.
**
****************************************************************/
-void test_h5p(void)
+void
+test_h5p(void)
{
/* Output message about test being performed */
MESSAGE(5, ("Testing Dataspaces\n"));
- test_h5p_basic(); /* Test basic H5P code */
-} /* test_h5p() */
-
+ test_h5p_basic(); /* Test basic H5P code */
+} /* test_h5p() */
diff --git a/test/theap.c b/test/theap.c
index 5a5bb72..fc9e391 100644
--- a/test/theap.c
+++ b/test/theap.c
@@ -1,16 +1,16 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: theap.c
- * Jul 17 1997
- * Robb Matzke <robb@maya.nuance.com>
+ * Created: theap.c
+ * Jul 17 1997
+ * Robb Matzke <robb@maya.nuance.com>
*
- * Purpose:
+ * Purpose:
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
@@ -21,68 +21,68 @@
#include <H5Fprivate.h>
#include <H5Hprivate.h>
-#define NOBJS 40
-
+#define NOBJS 40
/*-------------------------------------------------------------------------
- * Function: test_heap
+ * Function: test_heap
*
- * Purpose: Test name and object heaps.
+ * Purpose: Test name and object heaps.
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
- * robb@maya.nuance.com
- * Jul 17 1997
+ * Programmer: Robb Matzke
+ * robb@maya.nuance.com
+ * Jul 17 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
void
-test_heap (void)
+test_heap(void)
{
- int i, j;
- hid_t fid;
- H5F_t *f;
- haddr_t heap_addr;
- char buf[NOBJS+8];
- const char *s;
- size_t obj[NOBJS];
- herr_t status;
-
- MESSAGE (5, ("Testing Heaps\n"));
+ int i, j;
+ hid_t fid;
+ H5F_t *f;
+ haddr_t heap_addr;
+ char buf[NOBJS + 8];
+ const char *s;
+ size_t obj[NOBJS];
+ herr_t status;
- /* Create the file */
- fid = H5Fcreate ("theap.h5", H5ACC_OVERWRITE, 0, 0);
- CHECK (fid, FAIL, "H5Fcreate");
- f = H5Aatom_object (fid);
- CHECK (f, NULL, "H5Aatom_object");
+ MESSAGE(5, ("Testing Heaps\n"));
- /* Create a new heap */
- status = H5H_create (f, H5H_LOCAL, 0, &heap_addr/*out*/);
- CHECK_I (status, "H5H_new");
+ /* Create the file */
+ fid = H5Fcreate("theap.h5", H5ACC_OVERWRITE, 0, 0);
+ CHECK(fid, FAIL, "H5Fcreate");
+ f = H5Aatom_object(fid);
+ CHECK(f, NULL, "H5Aatom_object");
- /* Add stuff to the heap */
- for (i=0; i<NOBJS; i++) {
- sprintf (buf, "%03d-", i);
- for (j=4; j<i; j++) buf[j] = '0' + j%10;
- if (j>4) buf[j] = '\0';
+ /* Create a new heap */
+ status = H5H_create(f, H5H_LOCAL, 0, &heap_addr /*out */ );
+ CHECK_I(status, "H5H_new");
- obj[i] = H5H_insert (f, &heap_addr, strlen(buf)+1, buf);
- CHECK_I (obj[i], "H5H_insert");
- }
+ /* Add stuff to the heap */
+ for (i = 0; i < NOBJS; i++) {
+ sprintf(buf, "%03d-", i);
+ for (j = 4; j < i; j++)
+ buf[j] = '0' + j % 10;
+ if (j > 4)
+ buf[j] = '\0';
- /* Flush the cache and invalidate everything */
- H5AC_flush (f, NULL, 0, TRUE);
+ obj[i] = H5H_insert(f, &heap_addr, strlen(buf) + 1, buf);
+ CHECK_I(obj[i], "H5H_insert");
+ }
- /* Read the objects back out */
- for (i=0; i<NOBJS; i++) {
- s = H5H_peek (f, &heap_addr, obj[i]);
- MESSAGE (8, ("object is `%s'\n", s));
- }
+ /* Flush the cache and invalidate everything */
+ H5AC_flush(f, NULL, 0, TRUE);
- /* Close the file */
- H5Fclose (fid);
-}
+ /* Read the objects back out */
+ for (i = 0; i < NOBJS; i++) {
+ s = H5H_peek(f, &heap_addr, obj[i]);
+ MESSAGE(8, ("object is `%s'\n", s));
+ }
+ /* Close the file */
+ H5Fclose(fid);
+}
diff --git a/test/tmeta.c b/test/tmeta.c