forked from aws/aws-fpga
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
1018 lines (927 loc) · 53.1 KB
/
Jenkinsfile
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env groovy
//=============================================================================
// Pipeline parameters
//=============================================================================
properties([parameters([
string(name: 'branch', defaultValue: ''),
booleanParam(name: 'test_markdown_links', defaultValue: true, description: 'Test markdown files and check for broken links'),
booleanParam(name: 'test_src_headers', defaultValue: true, description: 'Check copyright heaers of source files'),
booleanParam(name: 'test_fpga_tools', defaultValue: true, description: 'Test fpga-* commands on F1'),
booleanParam(name: 'test_hdk_scripts', defaultValue: true, description: 'Test the HDK setup scripts'),
booleanParam(name: 'test_sims', defaultValue: true, description: 'Run all Simulations'),
booleanParam(name: 'test_edma', defaultValue: true, description: 'Run EDMA unit and perf tests'),
booleanParam(name: 'test_xdma', defaultValue: true, description: 'Test XDMA driver'),
booleanParam(name: 'test_runtime_software', defaultValue: true, description: 'Test precompiled AFIs'),
booleanParam(name: 'test_dcp_recipes', defaultValue: false, description: 'Run DCP generation with all clock recipes and build strategies.'),
booleanParam(name: 'test_hdk_fdf', defaultValue: true, description: 'Run Full developer flow testing on cl_hello_world and cl_dram_dma'),
booleanParam(name: 'test_sdaccel_scripts', defaultValue: true, description: 'Test SDAccel setup scripts'),
booleanParam(name: 'test_all_sdaccel_examples_fdf', defaultValue: false, description: 'Run Full Developer Flow testing of all SDAccel examples. This overrides test_helloworld_sdaccel_example'),
booleanParam(name: 'test_helloworld_sdaccel_example_fdf', defaultValue: true, description: 'Run Full Developer Flow testing of the Hello World SDAccel example'),
booleanParam(name: 'debug_dcp_gen', defaultValue: false, description: 'Only run FDF on cl_hello_world. Overrides test_*.'),
booleanParam(name: 'debug_fdf_uram', defaultValue: false, description: 'Debug the FDF for cl_uram_example.'),
booleanParam(name: 'fdf_ddr_comb', defaultValue: false, description: 'run FDF for cl_dram_dma ddr combinations.')
])])
//=============================================================================
// Configuration
//=============================================================================
boolean test_markdown_links = params.get('test_markdown_links')
boolean test_src_headers = params.get('test_src_headers')
boolean test_hdk_scripts = params.get('test_hdk_scripts')
boolean test_fpga_tools = params.get('test_fpga_tools')
boolean test_sims = params.get('test_sims')
boolean test_edma = params.get('test_edma')
boolean test_xdma = params.get('test_xdma')
boolean test_runtime_software = params.get('test_runtime_software')
boolean test_dcp_recipes = params.get('test_dcp_recipes')
boolean test_hdk_fdf = params.get('test_hdk_fdf')
boolean test_sdaccel_scripts = params.get('test_sdaccel_scripts')
boolean test_all_sdaccel_examples_fdf = params.get('test_all_sdaccel_examples_fdf')
boolean test_helloworld_sdaccel_example_fdf = params.get('test_helloworld_sdaccel_example_fdf')
def runtime_sw_cl_names = ['cl_dram_dma', 'cl_hello_world']
def dcp_recipe_cl_names = ['cl_dram_dma', 'cl_hello_world']
def dcp_recipe_scenarios = [
// Default values are tested in FDF: A0-B0-C0-DEFAULT
// Fastest clock speeds are: A1-B2-C0
// Test each clock recipe with the BASIC strategy
// Test all strategies with highest clock speeds
'A1-B1-C1-BASIC',
'A1-B2-C0-BASIC',
'A2-B3-C2-BASIC',
'A1-B4-C3-BASIC',
'A1-B5-C0-BASIC',
'A1-B2-C0-DEFAULT',
'A1-B2-C0-EXPLORE',
'A1-B2-C0-TIMING',
'A1-B2-C0-TIMING',
'A1-B2-C0-CONGESTION',
]
def fdf_test_names = ['cl_dram_dma[A0-B0-C0-DEFAULT]', 'cl_hello_world[A0-B0-C0-DEFAULT]', 'cl_hello_world_vhdl',
'cl_uram_example[2]', 'cl_uram_example[3]', 'cl_uram_example[4]']
boolean debug_dcp_gen = params.get('debug_dcp_gen')
if (debug_dcp_gen) {
fdf_test_names = ['cl_hello_world[A0-B0-C0-DEFAULT]']
test_markdown_links = false
test_sims = false
test_runtime_software = false
test_sdaccel_scripts = false
}
boolean debug_fdf_uram = params.get('debug_fdf_uram')
if (debug_fdf_uram) {
fdf_test_names = ['cl_uram_example[2]', 'cl_uram_example[3]', 'cl_uram_example[4]']
test_markdown_links = false
test_sims = false
test_runtime_software = false
test_sdaccel_scripts = false
}
boolean fdf_ddr_comb = params.get('fdf_ddr_comb')
if(fdf_ddr_comb) {
fdf_test_names = ['cl_dram_dma[A0-B0-C0-DEFAULT-111]', 'cl_dram_dma[A0-B0-C0-DEFAULT-110]', 'cl_dram_dma[A0-B0-C0-DEFAULT-101]','cl_dram_dma[A0-B0-C0-DEFAULT-100]','cl_dram_dma[A0-B0-C0-DEFAULT-011]','cl_dram_dma[A0-B0-C0-DEFAULT-010]','cl_dram_dma[A0-B0-C0-DEFAULT-001]','cl_dram_dma[A0-B0-C0-DEFAULT-000]']
test_markdown_links = false
test_sims = false
test_runtime_software = false
test_sdaccel_scripts = false
}
//=============================================================================
// Globals
//=============================================================================
// Map that contains stages of tests
def initial_tests = [:]
def secondary_tests = [:]
def multi_stage_tests = [:]
// Task to Label map
task_label = [
'create_afi': 't2.l_50',
'simulation': 'c4.xl',
'dcp_gen': 'c4.4xl',
'runtime': 'f1.2xl',
'runtime_all_slots': 'f1.16xl',
'source_scripts': 'c4.xl',
'md_links': 'c4.xl',
'find_tests': 't2.l_50',
'sdaccel_builds': 'c4.4xl'
]
def xilinx_versions = [ '2017.1', '2017.4' ]
def default_xilinx_version = xilinx_versions.last()
def dsa_map = [ '2017.1' : [ '1DDR' : '1ddr' , '4DDR' : '4ddr' , '4DDR_DEBUG' : '4ddr_debug' ],
'2017.4' : [ 'DYNAMIC_5_0' : 'dyn']
]
def sdaccel_example_default_map = [ '2017.1' : [ 'Hello_World_all': 'SDAccel/examples/xilinx/getting_started/host/helloworld_ocl',
'Gmem_2Banks_2ddr': 'SDAccel/examples/xilinx/getting_started/kernel_to_gmem/gmem_2banks_ocl',
'wide_mem_rw_ocl_4ddr': 'SDAccel/examples/xilinx/getting_started/kernel_to_gmem/wide_mem_rw_ocl',
'RTL_Vadd_Debug': 'SDAccel/examples/xilinx/getting_started/rtl_kernel/rtl_vadd'
],
'2017.4' : [ 'Hello_World_1ddr': 'SDAccel/examples/xilinx/getting_started/host/helloworld_ocl',
'Gmem_2Banks_2ddr': 'SDAccel/examples/xilinx/getting_started/kernel_to_gmem/gmem_2banks_ocl',
'kernel_3ddr_bandwidth_4ddr': 'SDAccel/examples/aws/kernel_3ddr_bandwidth',
'Kernel_Global_Bw_4ddr': 'SDAccel/examples/xilinx/getting_started/kernel_to_gmem/kernel_global_bandwidth',
'RTL_Vadd_Debug': 'SDAccel/examples/xilinx/getting_started/rtl_kernel/rtl_vadd_hw_debug'
]
]
// Get serializable entry set
@NonCPS def entrySet(m) {m.collect {k, v -> [key: k, value: v]}}
@NonCPS
def is_public_repo() {
echo "Change URL: ${env.CHANGE_URL}"
return (env.CHANGE_URL =~ /^(\S+)?aws-fpga\/pull\/(\d+)$/)
}
def get_task_label(Map args=[ : ]) {
String task_label = args.xilinx_version + '_' + task_label[args.task]
echo "Label Requested: $task_label"
return task_label
}
// Wait for input if we are running on a public repo to avoid malicious PRS
if (is_public_repo())
{
input "Running on a public repository, do you want to proceed with running the tests?"
}
else
{
echo "Running on a private repository"
}
//=============================================================================
// Shared Tests
//=============================================================================
if (test_markdown_links || test_src_headers) {
initial_tests['Documentation Tests'] = {
node(get_task_label(task: 'md_links', xilinx_version: default_xilinx_version)) {
checkout scm
if (test_markdown_links) {
stage('Test Markdown Links') {
String report_file = 'test_md_links.xml'
try {
sh """
set -e
source $WORKSPACE/shared/tests/bin/setup_test_env.sh
python2.7 -m pytest -v $WORKSPACE/shared/tests/test_md_links.py --junit-xml $WORKSPACE/${report_file}
"""
} finally {
if (fileExists(report_file)) {
junit healthScaleFactor: 10.0, testResults: report_file
}
else {
echo "Pytest wasn't run for stage. Report file not generated: ${report_file}"
}
}
}
}
if (test_src_headers) {
stage('Test Source Headers') {
String report_file = 'test_check_src_headers.xml'
checkout scm
try {
sh """
set -e
source $WORKSPACE/shared/tests/bin/setup_test_env.sh
python2.7 -m pytest -v $WORKSPACE/shared/tests/test_check_src_headers.py --junit-xml $WORKSPACE/${report_file}
"""
} finally {
if (fileExists(report_file)) {
junit healthScaleFactor: 10.0, testResults: report_file
}
else {
echo "Pytest wasn't run for stage. Report file not generated: ${report_file}"
}
}
}
}
}
}
}
//=============================================================================
// HDK Tests
//=============================================================================
if (test_hdk_scripts) {
initial_tests['Test HDK Scripts'] = {
stage('Test HDK Scripts') {
String report_file = 'test_hdk_scripts.xml'
node(get_task_label(task: 'source_scripts', xilinx_version: default_xilinx_version)) {
checkout scm
try {
sh """
set -e
source $WORKSPACE/shared/tests/bin/setup_test_env.sh
python2.7 -m pytest -v $WORKSPACE/hdk/tests/test_hdk_scripts.py --junit-xml $WORKSPACE/${report_file}
"""
} finally {
if (fileExists(report_file)) {
junit healthScaleFactor: 10.0, testResults: report_file
}
else {
echo "Pytest wasn't run for stage. Report file not generated: ${report_file}"
}
}
}
}
}
}
if (test_fpga_tools) {
secondary_tests['Test FPGA Tools 1 Slot'] = {
stage('Test FPGA Tools 1 Slot') {
String report_file = 'test_fpga_tools.xml'
node(get_task_label(task: 'runtime', xilinx_version: default_xilinx_version)) {
checkout scm
try {
sh """
set -e
source $WORKSPACE/shared/tests/bin/setup_test_sdk_env.sh
python2.7 -m pytest -v $WORKSPACE/sdk/tests/test_fpga_tools.py --junit-xml $WORKSPACE/${report_file}
"""
}
catch (exception) {
echo "Test FPGA Tools 1 Slot failed"
input message: "1 slot FPGA Tools test failed. Click Proceed or Abort when you are done debugging on the instance."
throw exception
}
finally {
if (fileExists(report_file)) {
junit healthScaleFactor: 10.0, testResults: report_file
}
else {
echo "Pytest wasn't run for stage. Report file not generated: ${report_file}"
}
}
}
}
}
secondary_tests['Test FPGA Tools All Slots'] = {
stage('Test FPGA Tools All Slots') {
String report_file = 'test_fpga_tools_all_slots.xml'
node(get_task_label(task: 'runtime_all_slots', xilinx_version: default_xilinx_version)) {
checkout scm
try {
sh """
set -e
source $WORKSPACE/shared/tests/bin/setup_test_sdk_env.sh
python2.7 -m pytest -v $WORKSPACE/sdk/tests/test_fpga_tools.py --junit-xml $WORKSPACE/${report_file}
"""
}
catch (exception) {
echo "Test FPGA Tools All Slots failed"
input message: "1 slot FPGA Tools test failed. Click Proceed or Abort when you are done debugging on the instance."
throw exception
}
finally {
if (fileExists(report_file)) {
junit healthScaleFactor: 10.0, testResults: report_file
}
else {
echo "Pytest wasn't run for stage. Report file not generated: ${report_file}"
}
}
}
}
}
}
if (test_sims) {
multi_stage_tests['Run Sims'] = {
stage('Run Sims') {
def cl_names = ['cl_uram_example', 'cl_dram_dma', 'cl_hello_world']
def sim_nodes = [:]
for (x in cl_names) {
for (y in xilinx_versions) {
String xilinx_version = y
String cl_name = x
String node_name = "Sim ${cl_name} ${xilinx_version}"
String key = "test_${cl_name}__"
String report_file = "test_sims_${cl_name}_${xilinx_version}.xml"
sim_nodes[node_name] = {
node(get_task_label(task: 'simulation', xilinx_version: xilinx_version)) {
checkout scm
try {
sh """
set -e
source $WORKSPACE/shared/tests/bin/setup_test_hdk_env.sh
python2.7 -m pytest -v $WORKSPACE/hdk/tests/simulation_tests/test_sims.py -k \"${key}\" --junit-xml $WORKSPACE/${report_file}
"""
} catch (exc) {
echo "${node_name} failed: archiving results"
archiveArtifacts artifacts: "hdk/cl/examples/${cl_name}/verif/sim/**", fingerprint: true
throw exc
} finally {
if (fileExists(report_file)) {
junit healthScaleFactor: 10.0, testResults: report_file
}
else {
echo "Pytest wasn't run for stage. Report file not generated: ${report_file}"
}
}
}
}
}
}
parallel sim_nodes
}
}
}
if (test_edma) {
secondary_tests['Test EDMA Driver'] = {
stage('Test EDMA Driver') {
node(get_task_label(task: 'runtime', xilinx_version: default_xilinx_version)) {
echo "Test EDMA Driver"
checkout scm
String test = "sdk/tests/test_edma.py"
String report_file = "test_edma.xml"
try {
sh """
set -e
source $WORKSPACE/shared/tests/bin/setup_test_sdk_env.sh
python2.7 -m pytest -v ${test} --junit-xml $WORKSPACE/${report_file}
"""
} catch (exc) {
echo "${test} failed."
junit healthScaleFactor: 10.0, testResults: report_file
input message: "EDMA driver test failed. Click Proceed or Abort when you are done debugging on the instance."
throw exc
} finally {
if (fileExists(report_file)) {
junit healthScaleFactor: 10.0, testResults: report_file
// archiveArtifacts artifacts: "sdk/tests/fio_dma_tools/scripts/*.csv", fingerprint: true
//archiveArtifacts artifacts: "/var/log/messages", fingerprint: true
}
else {
echo "Pytest wasn't run for stage. Report file not generated: ${report_file}"
}
}
}
}
}
}
if (test_xdma) {
secondary_tests['Test XDMA Driver'] = {
stage('Test XDMA Driver') {
node(get_task_label(task: 'runtime', xilinx_version: default_xilinx_version)) {
echo "Test XDMA Driver"
checkout scm
String test = "sdk/tests/test_xdma.py"
String report_file = "test_xdma.xml"
try {
sh """
set -e
source $WORKSPACE/shared/tests/bin/setup_test_sdk_env.sh
python2.7 -m pytest -v ${test} --junit-xml $WORKSPACE/${report_file}
"""
} catch (exc) {
echo "${test} failed."
junit healthScaleFactor: 10.0, testResults: report_file
input message: "XDMA driver test failed. Click Proceed or Abort when you are done debugging on the instance."
throw exc
} finally {
junit healthScaleFactor: 10.0, testResults: report_file
//archiveArtifacts artifacts: "sdk/tests/fio_dma_tools/scripts/*.csv", fingerprint: true
//archiveArtifacts artifacts: "/var/log/messages", fingerprint: true
}
}
}
}
}
if (test_runtime_software) {
multi_stage_tests['Test Runtime Software'] = {
stage('Test Runtime Software') {
def nodes = [:]
def node_types = ['runtime', 'runtime_all_slots']
for (n in node_types) {
node_type = n
for (x in runtime_sw_cl_names) {
String cl_name = x
String node_name = "Undefined"
switch (node_type) {
case "runtime":
node_name = "Test Runtime Software ${default_xilinx_version} f1.2xl ${cl_name}"
break;
case "runtime_all_slots":
node_name = "Test Runtime Software ${default_xilinx_version} f1.16xl ${cl_name}"
break;
}
String node_label = get_task_label(task: node_type, xilinx_version: default_xilinx_version)
nodes[node_name] = {
node(node_label) {
String test = "hdk/tests/test_load_afi.py::TestLoadAfi::test_precompiled_${cl_name}"
String report_file = "test_runtime_software_${cl_name}.xml"
checkout scm
try {
sh """
set -e
source $WORKSPACE/shared/tests/bin/setup_test_sdk_env.sh
python2.7 -m pytest -v ${test} --junit-xml $WORKSPACE/${report_file}
"""
} finally {
if (fileExists(report_file)) {
junit healthScaleFactor: 10.0, testResults: report_file
}
else {
echo "Pytest wasn't run for stage. Report file not generated: ${report_file}"
}
}
}
}
}
}
parallel nodes
}
}
}
if (test_dcp_recipes) {
multi_stage_tests['Test DCP Recipes'] = {
stage('Test DCP Recipes') {
def nodes = [:]
for (version in xilinx_versions) {
String xilinx_version = version
for (cl in dcp_recipe_cl_names) {
String cl_name = cl
for (s in dcp_recipe_scenarios) {
String recipe_scenario = s
String node_name = "Test DCP Recipe ${cl_name}[${xilinx_version}-${recipe_scenario}]"
nodes[node_name] = {
node(get_task_label(task: 'dcp_gen', xilinx_version: xilinx_version)) {
String test_name = "test_${cl_name}[${xilinx_version}-${recipe_scenario}]"
String report_file = "test_dcp_recipe_${cl_name}[${xilinx_version}-${recipe_scenario}].xml"
String build_dir = "hdk/cl/examples/${cl_name}/build"
checkout scm
try {
sh """
set -e
source $WORKSPACE/shared/tests/bin/setup_test_hdk_env.sh
python2.7 -m pytest -s -v hdk/tests/test_gen_dcp.py::TestGenDcp::${test_name} --junit-xml $WORKSPACE/${report_file} --xilinxVersion ${xilinx_version}
"""
} catch(exc) {
echo "${test_name} DCP generation failed: archiving results"
archiveArtifacts artifacts: "${build_dir}/**", fingerprint: true
throw exc
} finally {
if (fileExists(report_file)) {
junit healthScaleFactor: 10.0, testResults: report_file
}
else {
echo "Pytest wasn't run for stage. Report file not generated: ${report_file}"
}
}
}
}
}
}
}
parallel nodes
}
}
}
if (test_hdk_fdf) {
// Top level stage for FDF
// Each CL will have its own parallel FDF stage under this one.
multi_stage_tests['HDK_FDF'] = {
stage('HDK FDF') {
def fdf_stages = [:]
for (version in xilinx_versions) {
String xilinx_version = version
for (x in fdf_test_names) {
String fdf_test_name = x
String cl_name = ""
if (fdf_test_name.contains('[')) {
def split_test = fdf_test_name.split(/\[/)
def test_base_name = split_test[0]
def test_args = split_test[1]
fdf_test_name = "$test_base_name[$xilinx_version-$test_args"
cl_name = test_base_name
}
String fdf_stage_name = "FDF ${xilinx_version} ${fdf_test_name}"
fdf_stages[fdf_stage_name] = {
stage(fdf_stage_name) {
echo "Generate DCP for ${xilinx_version} ${fdf_test_name}"
String build_dir = "hdk/cl/examples/${cl_name}/build"
String dcp_stash_name = "dcp_tarball_${fdf_test_name}_${xilinx_version}".replaceAll(/[\[\]]/, "_")
String dcp_stash_dir = "${build_dir}/checkpoints/to_aws"
String afi_stash_name = "afi_${fdf_test_name}_${xilinx_version}".replaceAll(/[\[\]]/, "_")
String afi_stash_dir = "${build_dir}/create_afi"
echo "dcp_stash_name=${dcp_stash_name}"
echo "afi_stash_name=$afi_stash_name}"
node(get_task_label(task: 'dcp_gen', xilinx_version: xilinx_version)) {
String test = "hdk/tests/test_gen_dcp.py::TestGenDcp::test_${fdf_test_name}"
String report_file = "test_dcp_${fdf_test_name}_${xilinx_version}.xml"
checkout scm
// Clean out the to_aws directory to make sure there are no artifacts left over from a previous build
try {
sh """
rm -rf ${dcp_stash_dir}
"""
} catch(exc) {
// Ignore any errors
echo "Failed to clean ${dcp_stash_dir}"
}
try {
sh """
set -e
source $WORKSPACE/shared/tests/bin/setup_test_hdk_env.sh
python2.7 -m pytest -v ${test} --junit-xml $WORKSPACE/${report_file} --xilinxVersion ${xilinx_version}
"""
} catch (exc) {
echo "${fdf_test_name} DCP generation failed: archiving results"
archiveArtifacts artifacts: "${build_dir}/**", fingerprint: true
throw exc
} finally {
if (fileExists(report_file)) {
junit healthScaleFactor: 10.0, testResults: report_file
}
else {
echo "Pytest wasn't run for stage. Report file not generated: ${report_file}"
}
}
try {
stash name: dcp_stash_name, includes: "${dcp_stash_dir}/**"
} catch (exc) {
echo "stash ${dcp_stash_name} failed:\n${exc}"
}
}
node(get_task_label(task: 'create_afi', xilinx_version: xilinx_version)) {
echo "Generate AFI for ${xilinx_version} ${fdf_test_name}"
checkout scm
String test = "hdk/tests/test_create_afi.py::TestCreateAfi::test_${fdf_test_name}"
String report_file = "test_create_afi_${fdf_test_name}_${xilinx_version}.xml"
// Clean out the stash directories to make sure there are no artifacts left over from a previous build
try {
sh """
rm -rf ${dcp_stash_dir}
"""
} catch(exc) {
// Ignore any errors
echo "Failed to clean ${dcp_stash_dir}"
}
try {
sh """
rm -rf ${afi_stash_dir}
"""
} catch(exc) {
// Ignore any errors
echo "Failed to clean ${afi_stash_dir}"
}
try {
unstash name: dcp_stash_name
} catch (exc) {
echo "unstash ${dcp_stash_name} failed:\n${exc}"
//throw exc
}
try {
// There is a Xilinx bug that causes the following error during hdk_setup.sh if multiple
// processes are doing it at the same time:
// WARNING: [Common 17-1221] Tcl app 'xsim' is out of date for this release. Please run tclapp::reset_tclstore and reinstall the app.
// ERROR: [Common 17-685] Unable to load Tcl app xilinx::xsim
// ERROR: [Common 17-69] Command failed: ERROR: [Common 17-685] Unable to load Tcl app xilinx::xsim
sh """
set -e
source $WORKSPACE/shared/tests/bin/setup_test_env.sh
python2.7 -m pytest -v ${test} --junit-xml $WORKSPACE/${report_file} --xilinxVersion ${xilinx_version}
"""
} catch (exc) {
echo "${fdf_test_name} AFI generation failed: archiving results"
archiveArtifacts artifacts: "${build_dir}/to_aws/**", fingerprint: true
throw exc
} finally {
if (fileExists(report_file)) {
junit healthScaleFactor: 10.0, testResults: report_file
}
else {
echo "Pytest wasn't run for stage. Report file not generated: ${report_file}"
}
}
try {
stash name: afi_stash_name, includes: "${afi_stash_dir}/**"
} catch (exc) {
echo "stash ${afi_stash_name} failed:\n${exc}"
//throw exc
}
}
node(get_task_label(task: 'runtime', xilinx_version: xilinx_version)) {
String test = "hdk/tests/test_load_afi.py::TestLoadAfi::test_${fdf_test_name}"
String report_file = "test_load_afi_${fdf_test_name}_${xilinx_version}.xml"
checkout scm
echo "Test AFI for ${xilinx_version} ${fdf_test_name} on F1 instance"
// Clean out the stash directories to make sure there are no artifacts left over from a previous build
try {
sh """
rm -rf ${afi_stash_dir}
"""
} catch(exc) {
// Ignore any errors
echo "Failed to clean ${afi_stash_dir}"
}
try {
unstash name: afi_stash_name
} catch (exc) {
echo "unstash ${afi_stash_name} failed:\n${exc}"
//throw exc
}
try {
sh """
set -e
source $WORKSPACE/shared/tests/bin/setup_test_sdk_env.sh
python2.7 -m pytest -v ${test} --junit-xml $WORKSPACE/${report_file} --xilinxVersion ${xilinx_version}
"""
} finally {
if (fileExists(report_file)) {
junit healthScaleFactor: 10.0, testResults: report_file
}
else {
echo "Pytest wasn't run for stage. Report file not generated: ${report_file}"
}
}
}
}
}
} // for (x in fdf_test_names)
} // for (xilinx_version in xilinx_versions) {
parallel fdf_stages
}
}
}
//=============================================================================
// SDAccel Tests
//=============================================================================
if (test_sdaccel_scripts) {
initial_tests['Test SDAccel Scripts'] = {
stage('Test SDAccel Scripts') {
def nodes = [:]
for (def xilinx_version in xilinx_versions) {
String node_label = get_task_label(task: 'source_scripts', xilinx_version: xilinx_version)
String node_name = "Test SDAccel Scripts ${xilinx_version}"
nodes[node_name] = {
node(node_label) {
String report_file = "test_sdaccel_scripts_${xilinx_version}.xml"
checkout scm
try {
sh """
set -e
source $WORKSPACE/shared/tests/bin/setup_test_env.sh
python2.7 -m pytest -v $WORKSPACE/SDAccel/tests/test_sdaccel_scripts.py --junit-xml $WORKSPACE/${report_file}
"""
} finally {
if (fileExists(report_file)) {
junit healthScaleFactor: 10.0, testResults: report_file
}
else {
echo "Pytest wasn't run for stage. Report file not generated: ${report_file}"
}
}
}
}
}
parallel nodes
}
}
}
if (test_helloworld_sdaccel_example_fdf || test_all_sdaccel_examples_fdf) {
multi_stage_tests['Run SDAccel Tests'] = {
String sdaccel_examples_list = 'sdaccel_examples_list.json'
def sdaccel_all_version_stages = [:]
for (def version in xilinx_versions) {
String xilinx_version = version
String sdaccel_base_stage_name = "SDx FDF $xilinx_version"
String sdaccel_find_stage_name = "SDx Find tests $xilinx_version"
sdaccel_all_version_stages[sdaccel_base_stage_name] = {
stage (sdaccel_find_stage_name) {
node(get_task_label(task: 'find_tests', xilinx_version: xilinx_version)) {
checkout scm
String report_file = "test_find_sdaccel_examples_${xilinx_version}.xml"
try {
sh """
rm -rf ${sdaccel_examples_list}
"""
} catch(error) {
// Ignore any errors
echo "Failed to clean ${sdaccel_examples_list}"
}
try {
sh """
set -e
source $WORKSPACE/shared/tests/bin/setup_test_build_sdaccel_env.sh
python2.7 -m pytest -v $WORKSPACE/SDAccel/tests/test_find_sdaccel_examples.py --junit-xml $WORKSPACE/${report_file}
"""
} catch (exc) {
echo "Could not find tests. Please check the repository."
throw exc
} finally {
if (fileExists(report_file)) {
junit healthScaleFactor: 10.0, testResults: report_file
}
else {
echo "Pytest wasn't run for stage. Report file not generated: ${report_file}"
}
}
// Only run the hello world test by default
//def example_map = [ 'Hello_World': 'SDAccel/examples/xilinx/getting_started/host/helloworld_ocl' ]
def example_map = sdaccel_example_default_map.get(xilinx_version)
// Run all examples when parameter set
if (test_all_sdaccel_examples_fdf) {
example_map = readJSON file: sdaccel_examples_list
}
def sdaccel_build_stages = [:]
for ( def e in entrySet(example_map) ) {
String test_key = e.key
def dsa_map_for_version = dsa_map.get(xilinx_version)
def dsa_map_for_test = [:]
if(xilinx_version == '2017.4') {
dsa_map_for_test = dsa_map_for_version
} else {
echo "in xilinx_version 2017.1"
if(test_key =~ '_all') {
dsa_map_for_test = dsa_map_for_version
} else if(test_key =~ '_1ddr') {
dsa_map_for_test.put("1DDR", dsa_map_for_version.get("1DDR"))
} else if(test_key =~ '_2ddr') {
dsa_map_for_test.put("4DDR", dsa_map_for_version.get("4DDR"))
} else if(test_key =~ '_4ddr') {
dsa_map_for_test.put("4DDR", dsa_map_for_version.get("4DDR"))
} else if(test_key =~ '_Debug') {
dsa_map_for_test.put("4DDR_DEBUG", dsa_map_for_version.get("4DDR_DEBUG"))
} else {
dsa_map_for_test.put("4DDR", dsa_map_for_version.get("4DDR"))
}
}
Boolean test_sw_emu_supported = true
if(test_key =~ '_Debug') {
test_sw_emu_supported = false
}
// dsa = [ 4DDR: 4ddr ]
for ( def dsa in entrySet(dsa_map_for_test) ) {
String build_name = "SDx ${e.key}_${dsa.value}_${xilinx_version}"
String example_path = e.value
String dsa_name = dsa.key
String dsa_rte_name = dsa.value
String sw_emu_stage_name = "SDx SW_EMU ${build_name}"
String hw_emu_stage_name = "SDx HW_EMU ${build_name}"
String hw_stage_name = "SDx HW ${build_name}"
String create_afi_stage_name = "SDx AFI ${build_name}"
String run_example_stage_name = "SDx RUN ${build_name}"
String sw_emu_report_file = "sdaccel_sw_emu_${e.key}_${dsa.value}_${xilinx_version}.xml"
String hw_emu_report_file = "sdaccel_hw_emu_${e.key}_${dsa.value}_${xilinx_version}.xml"
String hw_report_file = "sdaccel_hw_${e.key}_${dsa.value}_${xilinx_version}.xml"
String create_afi_report_file = "sdaccel_create_afi_${e.key}_${dsa.value}_${xilinx_version}.xml"
String run_example_report_file = "sdaccel_run_${e.key}_${dsa.value}_${xilinx_version}.xml"
sdaccel_build_stages[build_name] = {
if(test_sw_emu_supported) {
stage(sw_emu_stage_name) {
node(get_task_label(task: 'sdaccel_builds', xilinx_version: xilinx_version)) {
checkout scm
try {
sh """
set -e
source $WORKSPACE/shared/tests/bin/setup_test_build_sdaccel_env.sh
export AWS_PLATFORM=\$AWS_PLATFORM_${dsa_name}
python2.7 -m pytest -v $WORKSPACE/SDAccel/tests/test_build_sdaccel_example.py::TestBuildSDAccelExample::test_sw_emu --examplePath ${example_path} --junit-xml $WORKSPACE/${sw_emu_report_file} --timeout=14400 --rteName ${dsa_rte_name} --xilinxVersion ${xilinx_version}
"""
} catch (error) {
echo "${sw_emu_stage_name} SW EMU Build generation failed"
archiveArtifacts artifacts: "${example_path}/**", fingerprint: true
throw error
} finally {
if (fileExists(sw_emu_report_file)) {
junit healthScaleFactor: 10.0, testResults: sw_emu_report_file
}
else {
echo "Pytest wasn't run for stage. Report file not generated: ${sw_emu_report_file}"
}
sh """
set -e
sudo git reset --hard
sudo git clean -fdx
"""
}
}
}
}
stage(hw_emu_stage_name) {
node(get_task_label(task: 'sdaccel_builds', xilinx_version: xilinx_version)) {
checkout scm
try {
sh """
set -e
source $WORKSPACE/shared/tests/bin/setup_test_build_sdaccel_env.sh
export AWS_PLATFORM=\$AWS_PLATFORM_${dsa_name}
python2.7 -m pytest -v $WORKSPACE/SDAccel/tests/test_build_sdaccel_example.py::TestBuildSDAccelExample::test_hw_emu --examplePath ${example_path} --junit-xml $WORKSPACE/${hw_emu_report_file} --timeout=21600 --rteName ${dsa_rte_name} --xilinxVersion ${xilinx_version}
"""
} catch (error) {
echo "${hw_emu_stage_name} HW EMU Build generation failed"
archiveArtifacts artifacts: "${example_path}/**", fingerprint: true
throw error
} finally {
if (fileExists(hw_emu_report_file)) {
junit healthScaleFactor: 10.0, testResults: hw_emu_report_file
}
else {
echo "Pytest wasn't run for stage. Report file not generated: ${hw_emu_report_file}"
}
sh """
set -e
sudo git reset --hard
sudo git clean -fdx
"""
}
}
}
stage(hw_stage_name) {
node(get_task_label(task: 'sdaccel_builds', xilinx_version: xilinx_version)) {
checkout scm
try {
sh """
set -e
source $WORKSPACE/shared/tests/bin/setup_test_build_sdaccel_env.sh
export AWS_PLATFORM=\$AWS_PLATFORM_${dsa_name}
python2.7 -m pytest -s -v $WORKSPACE/SDAccel/tests/test_build_sdaccel_example.py::TestBuildSDAccelExample::test_hw_build --examplePath ${example_path} --junit-xml $WORKSPACE/${hw_report_file} --timeout=36000 --rteName ${dsa_rte_name} --xilinxVersion ${xilinx_version}
"""
} catch (error) {
echo "${hw_stage_name} HW Build generation failed"
archiveArtifacts artifacts: "${example_path}/**", fingerprint: true
throw error
} finally {
if (fileExists(hw_report_file)) {
junit healthScaleFactor: 10.0, testResults: hw_report_file
}
else {
echo "Pytest wasn't run for stage. Report file not generated: ${hw_report_file}"
}
sh """
set -e
sudo git reset --hard
sudo git clean -fdx
"""
}
}
}
stage(create_afi_stage_name) {
node(get_task_label(task: 'create_afi', xilinx_version: xilinx_version)) {
checkout scm
try {
sh """
set -e
source $WORKSPACE/shared/tests/bin/setup_test_build_sdaccel_env.sh
export AWS_PLATFORM=\$AWS_PLATFORM_${dsa_name}
python2.7 -m pytest -s -v $WORKSPACE/SDAccel/tests/test_create_sdaccel_afi.py::TestCreateSDAccelAfi::test_create_sdaccel_afi --examplePath ${example_path} --junit-xml $WORKSPACE/${create_afi_report_file} --timeout=18000 --rteName ${dsa_rte_name} --xilinxVersion ${xilinx_version}
"""
} catch (error) {
echo "${create_afi_stage_name} Create AFI failed"
archiveArtifacts artifacts: "${example_path}/**", fingerprint: true
throw error
} finally {
if (fileExists(create_afi_report_file)) {
junit healthScaleFactor: 10.0, testResults: create_afi_report_file
}
else {
echo "Pytest wasn't run for stage. Report file not generated: ${create_afi_report_file}"
}
String to_aws_dir = "${example_path}/to_aws"
if (fileExists(to_aws_dir)) {
sh "rm -rf ${to_aws_dir}"
}
sh """
set -e
sudo git reset --hard
sudo git clean -fdx
"""
}
}
}
stage(run_example_stage_name) {
node(get_task_label(task: 'runtime', xilinx_version: xilinx_version)) {
checkout scm
try {
sh """
set -e
source $WORKSPACE/shared/tests/bin/setup_test_runtime_sdaccel_env.sh
export AWS_PLATFORM=\$AWS_PLATFORM_${dsa_name}
python2.7 -m pytest -v $WORKSPACE/SDAccel/tests/test_run_sdaccel_example.py::TestRunSDAccelExample::test_run_sdaccel_example --examplePath ${example_path} --junit-xml $WORKSPACE/${run_example_report_file} --timeout=14400 --rteName ${dsa_rte_name} --xilinxVersion ${xilinx_version}
"""
} catch (error) {
echo "${run_example_stage_name} Runtime example failed"
archiveArtifacts artifacts: "${example_path}/**", fingerprint: true
input message: "SDAccel Runtime test failed. Click Proceed or Abort when you are done debugging on the instance."
throw error
} finally {
if (fileExists(run_example_report_file)) {
junit healthScaleFactor: 10.0, testResults: run_example_report_file
}
else {
echo "Pytest wasn't run for stage. Report file not generated: ${run_example_report_file}"
}
sh """
set -e
sudo git reset --hard
sudo git clean -fdx
"""
}
}
}
} // sdaccel_build_stages[ e.key ]
} //for ( def dsa in entrySet(dsa_map_for_test) ) {
} // for ( e in list_map )