summaryrefslogtreecommitdiffstats
path: root/examples/CMakeLists.txt
blob: 10c6ede7251e60e177fb65089da0eeedce242b04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
cmake_minimum_required (VERSION 3.18)
project (HDF5_EXAMPLES C)

#-----------------------------------------------------------------------------
# Define Sources
#-----------------------------------------------------------------------------
set (examples
    h5_crtdat
    h5_rdwt
    h5_crtatt
    h5_crtgrp
    h5_crtgrpar
    h5_crtgrpd
    h5_cmprss
    h5_extend
    h5_subset
    h5_write
    h5_read
    h5_extend_write
    h5_chunk_read
    h5_compound
    h5_group
    h5_select
    h5_attribute
    h5_mount
    h5_ref_extern
    h5_ref_compat
    h5_reference_deprec
    h5_drivers
    h5_ref2reg_deprec
    h5_extlink
    h5_elink_unix2win
    h5_shared_mesg
    h5_debug_trace
    h5_vds
    h5_vds-exc
    h5_vds-exclim
    h5_vds-eiger
    h5_vds-simpleIO
    h5_vds-percival
    h5_vds-percival-unlim
    h5_vds-percival-unlim-maxmin
)

if (H5_HAVE_PARALLEL)
  set (parallel_examples
    ph5example
    ph5_filtered_writes
    ph5_filtered_writes_no_sel
  )

  if (HDF5_ENABLE_SUBFILING_VFD)
    list (APPEND parallel_examples ph5_subfiling)
  endif ()
endif ()

foreach (example ${examples})
  add_executable (${example} ${HDF5_EXAMPLES_SOURCE_DIR}/${example}.c)
  target_include_directories (${example} PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
  if (NOT BUILD_SHARED_LIBS)
    TARGET_C_PROPERTIES (${example} STATIC)
    target_link_libraries (${example} PRIVATE ${HDF5_LIB_TARGET})
  else ()
    TARGET_C_PROPERTIES (${example} SHARED)
    target_link_libraries (${example} PRIVATE ${HDF5_LIBSH_TARGET})
  endif ()
  set_target_properties (${example} PROPERTIES FOLDER examples)

  #-----------------------------------------------------------------------------
  # Add Target to clang-format
  #-----------------------------------------------------------------------------
  if (HDF5_ENABLE_FORMATTERS)
    clang_format (HDF5_EXAMPLES_${example}_FORMAT ${example})
  endif ()
endforeach ()

if (H5_HAVE_PARALLEL)
  foreach (parallel_example ${parallel_examples})
    add_executable (${parallel_example} ${HDF5_EXAMPLES_SOURCE_DIR}/${parallel_example}.c)
    target_include_directories (${parallel_example} PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
    if (NOT BUILD_SHARED_LIBS)
      TARGET_C_PROPERTIES (${parallel_example} STATIC)
      target_link_libraries (${parallel_example} PRIVATE ${HDF5_LIB_TARGET} MPI::MPI_C)
    else ()
      TARGET_C_PROPERTIES (${parallel_example} SHARED)
      target_link_libraries (${parallel_example} PRIVATE ${HDF5_LIBSH_TARGET} MPI::MPI_C)
    endif ()
    set_target_properties (${parallel_example} PROPERTIES FOLDER examples)

    #-----------------------------------------------------------------------------
    # Add Target to clang-format
    #-----------------------------------------------------------------------------
    if (HDF5_ENABLE_FORMATTERS)
      clang_format (HDF5_EXAMPLES_${parallel_example}_FORMAT ${parallel_example})
    endif ()
  endforeach ()
endif ()

if (BUILD_TESTING AND HDF5_TEST_EXAMPLES)
  include (CMakeTests.cmake)
endif ()
ore_8_5_19_rc'>core_8_5_19_rc Tcl is a high-level, general-purpose, interpreted, dynamic programming language. It was designed with the goal of being very simple but powerful.
summaryrefslogtreecommitdiffstats
path: root/tests/link.test
blob: 843333b7f35cfceb07e01a96ecf9d787c269e794 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# Commands covered:  none
#
# This file contains a collection of tests for Tcl_LinkVar and related
# library procedures.  Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 1993 The Regents of the University of California.
# Copyright (c) 1994 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: link.test,v 1.4 1999/06/26 03:54:16 jenn Exp $

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest
    namespace import ::tcltest::*
}

if {[info commands testlink] == {}} {
    puts "This application hasn't been compiled with the \"testlink\""
    puts "command, so I can't test Tcl_LinkVar et al."
    ::tcltest::cleanupTests
    return
}

foreach i {int real bool string} {
    catch {unset $i}
}
test link-1.1 {reading C variables from Tcl} {
    testlink delete
    testlink set 43 1.23 4 -
    testlink create 1 1 1 1
    list $int $real $bool $string
} {43 1.23 1 NULL}
test link-1.2 {reading C variables from Tcl} {
    testlink delete
    testlink create 1 1 1 1
    testlink set -3 2 0 "A long string with spaces"
    list $int $real $bool $string $int $real $bool $string
} {-3 2.0 0 {A long string with spaces} -3 2.0 0 {A long string with spaces}}

test link-2.1 {writing C variables from Tcl} {
    testlink delete
    testlink set 43 1.21 4 -
    testlink create 1 1 1 1
    set int "00721"
    set real -10.5
    set bool true
    set string abcdef
    concat [testlink get] $int $real $bool $string
} {465 -10.5 1 abcdef 00721 -10.5 true abcdef}
test link-2.2 {writing bad values into variables} {
    testlink delete
    testlink set 43 1.23 4 -
    testlink create 1 1 1 1
    list [catch {set int 09a} msg] $msg $int
} {1 {can't set "int": variable must have integer value} 43}
test link-2.3 {writing bad values into variables} {
    testlink delete
    testlink set 43 1.23 4 -
    testlink create 1 1 1 1
    list [catch {set real 1.x3} msg] $msg $real
} {1 {can't set "real": variable must have real value} 1.23}
test link-2.4 {writing bad values into variables} {
    testlink delete
    testlink set 43 1.23 4 -
    testlink create 1 1 1 1
    list [catch {set bool gorp} msg] $msg $bool
} {1 {can't set "bool": variable must have boolean value} 1}

test link-3.1 {read-only variables} {
    testlink delete
    testlink set 43 1.23 4 -
    testlink create 0 1 1 0
    list [catch {set int 4} msg] $msg $int \
	[catch {set real 10.6} msg] $msg $real \
	[catch {set bool no} msg] $msg $bool \
	[catch {set string "new value"} msg] $msg $string
} {1 {can't set "int": linked variable is read-only} 43 0 10.6 10.6 0 no no 1 {can't set "string": linked variable is read-only} NULL}
test link-3.2 {read-only variables} {
    testlink delete
    testlink set 43 1.23 4 -
    testlink create 1 0 0 1
    list [catch {set int 4} msg] $msg $int \
	[catch {set real 10.6} msg] $msg $real \
	[catch {set bool no} msg] $msg $bool \
	[catch {set string "new value"} msg] $msg $string
} {0 4 4 1 {can't set "real": linked variable is read-only} 1.23 1 {can't set "bool": linked variable is read-only} 1 0 {new value} {new value}}

test link-4.1 {unsetting linked variables} {
    testlink delete
    testlink set -6 -2.5 0 stringValue
    testlink create 1 1 1 1
    unset int real bool string
    list [catch {set int} msg] $msg [catch {set real} msg] $msg \
	    [catch {set bool} msg] $msg [catch {set string} msg] $msg
} {0 -6 0 -2.5 0 0 0 stringValue}
test link-4.2 {unsetting linked variables} {
    testlink delete
    testlink set -6 -2.1 0 stringValue
    testlink create 1 1 1 1
    unset int real bool string
    set int 102
    set real 16
    set bool true
    set string newValue
    testlink get
} {102 16.0 1 newValue}

test link-5.1 {unlinking variables} {
    testlink delete
    testlink set -6 -2.25 0 stringValue
    testlink delete
    set int xx1
    set real qrst
    set bool bogus
    set string 12345
    testlink get
} {-6 -2.25 0 stringValue}
test link-5.2 {unlinking variables} {
    testlink delete
    testlink set -6 -2.25 0 stringValue
    testlink create 1 1 1 1
    testlink delete
    testlink set 25 14.7 7 -
    list $int $real $bool $string
} {-6 -2.25 0 stringValue}

test link-6.1 {errors in setting up link} {
    testlink delete
    catch {unset int}
    set int(44) 1
    list [catch {testlink create 1 1 1 1} msg] $msg
} {1 {can't set "int": variable is array}}
catch {unset int}

test link-7.1 {access to linked variables via upvar} {
    proc x {} {
	upvar int y
	unset y
    }
    testlink delete
    testlink create 1 0 0 0
    testlink set 14 {} {} {}
    x
    list [catch {set int} msg] $msg
} {0 14}
test link-7.2 {access to linked variables via upvar} {
    proc x {} {
	upvar int y
	return [set y]
    }
    testlink delete
    testlink create 1 0 0 0
    testlink set 0 {} {} {}
    set int
    testlink set 23 {} {} {}
    x
    list [x] $int
} {23 23}
test link-7.3 {access to linked variables via upvar} {
    proc x {} {
	upvar int y
	set y 44
    }
    testlink delete
    testlink create 0 0 0 0
    testlink set 11 {} {} {}
    list [catch x msg] $msg $int
} {1 {can't set "y": linked variable is read-only} 11}
test link-7.4 {access to linked variables via upvar} {
    proc x {} {
	upvar int y
	set y abc
    }
    testlink delete
    testlink create 1 1 1 1
    testlink set -4 {} {} {}
    list [catch x msg] $msg $int
} {1 {can't set "y": variable must have integer value} -4}
test link-7.5 {access to linked variables via upvar} {
    proc x {} {
	upvar real y
	set y abc
    }
    testlink delete
    testlink create 1 1 1 1
    testlink set -4 16.75 {} {}
    list [catch x msg] $msg $real
} {1 {can't set "y": variable must have real value} 16.75}
test link-7.6 {access to linked variables via upvar} {
    proc x {} {
	upvar bool y
	set y abc
    }
    testlink delete
    testlink create 1 1 1 1
    testlink set -4 16.3 1 {}
    list [catch x msg] $msg $bool
} {1 {can't set "y": variable must have boolean value} 1}

test link-8.1 {Tcl_UpdateLinkedVar procedure} {
    proc x args {
	global x int real bool string
	lappend x $args $int $real $bool $string
    }
    set x {}
    testlink create 1 1 1 1
    testlink set 14 -2.0 0 xyzzy
    trace var int w x
    testlink update 32 4.0 3 abcd
    trace vdelete int w x
    set x
} {{int {} w} 32 -2.0 0 xyzzy}
test link-8.2 {Tcl_UpdateLinkedVar procedure} {
    proc x args {
	global x int real bool string
	lappend x $args $int $real $bool $string
    }
    set x {}
    testlink create 1 1 1 1
    testlink set 14 -2.0 0 xyzzy
    testlink delete
    trace var int w x
    testlink update 32 4.0 6 abcd
    trace vdelete int w x
    set x
} {}
test link-8.3 {Tcl_UpdateLinkedVar procedure, read-only variable} {
    testlink create 0 0 0 0
    list [catch {testlink update 47 {} {} {}} msg] $msg $int
} {0 {} 47}

testlink set 0 0 0 -
testlink delete
foreach i {int real bool string} {
    catch {unset $i}
}

# cleanup
::tcltest::cleanupTests
return