forked from rr-debugger/rr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
763 lines (700 loc) · 21.3 KB
/
CMakeLists.txt
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
# *-* Mode: cmake; *-*
cmake_minimum_required(VERSION 2.8.5)
project(rr C CXX ASM)
enable_testing()
set(BUILD_SHARED_LIBS ON)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
# CAREFUL! "-" is an invalid character in RPM package names, while
# debian is happy with it. However, "_" is illegal in debs, while RPM
# is cool with it. Sigh.
set(rr_VERSION_MAJOR 3)
set(rr_VERSION_MINOR 2)
set(rr_VERSION_PATCH 0)
add_definitions(-DRR_VERSION="${rr_VERSION_MAJOR}.${rr_VERSION_MINOR}.${rr_VERSION_PATCH}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread -O0 -g3 -Wall -Werror -Wstrict-prototypes")
# Define __STDC_LIMIT_MACROS so |#include <stdint.h>| works as expected.
# Define __STDC_FORMAT_MACROS so |#include <inttypes.h>| works as expected.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__USE_LARGEFILE64 -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -std=c++0x -pthread -O0 -g3 -Wall -Werror")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -g3")
# Check that a 32-bit cross-compile works. This is needed regardless
# of whether the entire build is being built 32-bit.
if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
# try_compile won't accept LINK_FLAGS, so do this manually.
file(WRITE "${CMAKE_BINARY_DIR}/test32.c" "int main() { return 0; }")
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -o ${CMAKE_BINARY_DIR}/test32 ${CMAKE_BINARY_DIR}/test32.c -m32
RESULT_VARIABLE COMPILER_32BIT_RESULT)
if(NOT (COMPILER_32BIT_RESULT EQUAL 0))
message(FATAL_ERROR "Your toolchain doesn't support 32-bit cross-compilation.")
endif()
endif()
option(force32bit, "Force a 32-bit build, rather than a 64-bit one")
if(force32bit)
set(rr_64BIT false)
set(rr_MBITNESS_OPTION -m32)
else()
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(rr_64BIT true)
else()
set(rr_64BIT false)
endif()
set(rr_MBITNESS_OPTION)
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${rr_MBITNESS_OPTION}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${rr_MBITNESS_OPTION}")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${rr_MBITNESS_OPTION}")
find_package(PkgConfig REQUIRED)
# If we're cross-compiling a 32-bit build on a 64-bit host we need
# to ensure we're looking for the right libraries.
# This has been tested on Ubuntu and Fedora.
set(LIBDIR32_CANDIDATES
/usr/lib/i386-linux-gnu/pkgconfig/
/usr/lib/pkgconfig/
)
if((NOT rr_64BIT) AND CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
foreach(libdir ${LIBDIR32_CANDIDATES})
if(IS_DIRECTORY ${libdir})
set(ENV{PKG_CONFIG_LIBDIR} ${libdir})
break()
endif()
endforeach(libdir)
if (NOT DEFINED ENV{PKG_CONFIG_LIBDIR})
message(FATAL_ERROR "Couldn't find a suitable 32-bit pkgconfig lib dir. You probably need to install a 32-bit pkgconfig package (pkgconfig.i686 for Fedora or pkg-config:i386 for Ubuntu")
endif()
endif()
# Check for required libraries
set(REQUIRED_LIBS
zlib
)
foreach(required_lib ${REQUIRED_LIBS})
string(TOUPPER ${required_lib} PKG)
pkg_check_modules(${PKG} REQUIRED ${required_lib})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${${PKG}_CFLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${${PKG}_CFLAGS}")
endforeach(required_lib)
# Check for Python >=2.7 but not Python 3.
find_package(PythonInterp 2.7 REQUIRED)
if(PYTHON_VERSION_MAJOR GREATER 2)
message(FATAL_ERROR "Python 3 is not supported, please use Python 2.7.")
endif()
# Check for required Python modules
set(REQUIRED_PYTHON_MODULES
pexpect
)
foreach(py_module ${REQUIRED_PYTHON_MODULES})
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
"import ${py_module}"
RESULT_VARIABLE module_status)
if(module_status)
message(FATAL_ERROR "Couldn't find required Python module ${py_module}.")
endif()
endforeach(py_module)
set_source_files_properties(src/preload/preload.c PROPERTIES COMPILE_FLAGS -O2)
include_directories("${PROJECT_SOURCE_DIR}/include")
# We need to know where our generated files are.
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
add_library(rrpreload
src/preload/preload.c
src/preload/traced_syscall.S
src/preload/untraced_syscall.S
src/preload/syscall_hook.S
)
# Ensure that CMake knows about our generated files.
#
# Alphabetical, please.
set(GENERATED_FILES
AssemblyTemplates.generated
CheckSyscallNumbers.generated
IsAlwaysEmulatedSyscall.generated
SyscallDefsTable.generated
SyscallEnumsX64.generated
SyscallEnumsX86.generated
SyscallEnumsForTestsX64.generated
SyscallEnumsForTestsX86.generated
SyscallHelperFunctions.generated
SyscallnameArch.generated
SyscallRecordCase.generated
)
foreach(generated_file ${GENERATED_FILES})
set_source_files_properties(${generated_file}
PROPERTIES GENERATED true HEADER_FILE_ONLY true)
add_custom_command(OUTPUT ${generated_file}
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/src/generate_syscalls.py"
"${CMAKE_CURRENT_BINARY_DIR}/${generated_file}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/generate_syscalls.py"
"${CMAKE_CURRENT_SOURCE_DIR}/src/syscalls.py"
"${CMAKE_CURRENT_SOURCE_DIR}/src/assembly_templates.py")
endforeach(generated_file)
add_custom_target(Generated DEPENDS ${GENERATED_FILES})
add_executable(rr
src/test/cpuid_loop.S
src/AddressSpace.cc
src/AutoRemoteSyscalls.cc
src/Command.cc
src/CompressedReader.cc
src/CompressedWriter.cc
src/CPUIDBugDetector.cc
src/DiversionSession.cc
src/DumpCommand.cc
src/EmuFs.cc
src/Event.cc
src/ExtraRegisters.cc
src/fast_forward.cc
src/FdTable.cc
src/Flags.cc
src/GdbConnection.cc
src/GdbInitCommand.cc
src/GdbServer.cc
src/HelpCommand.cc
src/kernel_abi.cc
src/kernel_metadata.cc
src/log.cc
src/MagicSaveDataMonitor.cc
src/main.cc
src/Monkeypatcher.cc
src/PerfCounters.cc
src/PsCommand.cc
src/RecordCommand.cc
src/RecordSession.cc
src/record_signal.cc
src/record_syscall.cc
src/Registers.cc
src/remote_code_ptr.cc
src/ReplayCommand.cc
src/ReplaySession.cc
src/replay_syscall.cc
src/ReplayTimeline.cc
src/Scheduler.cc
src/Session.cc
src/StdioMonitor.cc
src/task.cc
src/TraceFrame.cc
src/TraceStream.cc
src/util.cc
)
add_dependencies(rr Generated)
target_link_libraries(rr
-ldl
-lrt
${ZLIB_LDFLAGS}
)
target_link_libraries(rrpreload
-ldl
)
install(PROGRAMS scripts/signal-rr-recording.sh
DESTINATION bin)
install(TARGETS rr rrpreload
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
# Build 32-bit librrpreload on 64-bit builds.
# We copy the source files into '32' subdirectories in the output
# directory, so we can set different compile options on them.
# This sucks but I can't find a better way to get CMake to build
# the same source file in two different ways.
if(rr_64BIT)
foreach(file preload_interface.h traced_syscall_shared.S)
set_source_files_properties(32/${file}
PROPERTIES GENERATED true HEADER_FILE_ONLY true)
add_custom_command(OUTPUT 32/${file}
COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/32 &&
cp "${CMAKE_CURRENT_SOURCE_DIR}/src/preload/${file}"
"${CMAKE_CURRENT_BINARY_DIR}/32/${file}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/preload/${file}")
endforeach(file)
foreach(file preload.c traced_syscall.S untraced_syscall.S syscall_hook.S)
set_source_files_properties(32/${file}
PROPERTIES GENERATED true COMPILE_FLAGS "-m32 -O2")
add_custom_command(OUTPUT 32/${file}
COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/32 &&
cp "${CMAKE_CURRENT_SOURCE_DIR}/src/preload/${file}"
"${CMAKE_CURRENT_BINARY_DIR}/32/${file}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/preload/${file}"
32/preload_interface.h 32/traced_syscall_shared.S)
endforeach(file)
add_library(rrpreload_32
32/preload.c
32/traced_syscall.S
32/untraced_syscall.S
32/syscall_hook.S
)
set_target_properties(rrpreload_32 PROPERTIES LINK_FLAGS -m32)
target_link_libraries(rrpreload_32
-ldl
)
install(TARGETS rrpreload_32
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
endif()
##--------------------------------------------------
## Testing
# A "basic test" consists of a foo.c source file. All basic tests use the
# same basic_test.run driver script. The test name is passed as an additional
# parameter to the driver script. This script just does
# "compare_test EXIT-SUCCESS", i.e. records and replays the program and verifies
# that the output of both runs is identical and contains EXIT-SUCCESS.
#
# NB: you must update this variable when adding a new test source
# file. The list is not generated automatically.
#
# Alphabetical, please.
set(BASIC_TESTS
64bit_child
accept
alarm
alarm2
async_segv_ignored
async_signal_syscalls2
at_threadexit
bad_ip
bad_syscall
barrier
big_buffers
block
blocked_sigsegv
brk
chew_cpu
chown
clock
clone
clone_bad_stack
clone_untraced
constructor
desched_blocking_poll
dup
epoll_create
epoll_create1
exec_self
fadvise
fault_in_code_page
fcntl_owner_ex
flock
fork_child_crash
fork_stress
fxregs
getgroups
getrandom
setitimer
getsid
gettimeofday
grandchild_threads
grandchild_threads_main_running
grandchild_threads_thread_running
grandchild_threads_parent_alive
ignored_sigsegv
int3
intr_futex_wait_restart
intr_poll
intr_pselect
intr_read_no_restart
intr_read_restart
intr_sleep
intr_sleep_no_restart
invalid_fcntl
io
legacy_ugid
madvise
map_fixed
mincore
mmap_discontinuous
mmap_private
mmap_ro
mmap_shared
mmap_shared_subpage
mmap_short_file
mmap_tmpfs
mprotect
mprotect_heterogenous
mprotect_stack
mremap
msg
msync
multiple_pending_signals
multiple_pending_signals_sequential
munmap_segv
munmap_discontinuous
no_mask_timeslice
numa
old_fork
orphan_process
pause
perf_event
poll_sig_race
prctl
prctl_deathsig
prctl_name
protect_rr_fds
prw
pthread_condvar_locking
ptrace
ptrace_attach_null_status
ptrace_attach_running
ptrace_attach_sleeping
ptrace_attach_stopped
ptrace_attach_thread_running
ptracer_death
ptracer_death_multithread
ptracer_death_multithread_peer
quotactl
rdtsc
readdir
readlink
readv
rlimit
rusage
save_data_fd
sched_setaffinity
sched_yield
sched_yield_to_lower_priority
scm_rights
seccomp
seccomp_null
sem
sendfile
set_ptracer
setgid
setsid
shm
sigaction_old
sigaltstack
sigchld_interrupt_signal
sighandler_fork
sigill
signalfd
sigprocmask
sigqueueinfo
sigreturn
sigreturn_reg
sigrt
sigstop
sigstop2
sigsuspend
sigtrap
simple
sioc
sock_names_opts
splice
statfs
stdout_child
stdout_cloexec
stdout_dup
stdout_redirect
strict_priorities
switch_read
syscallbuf_timeslice
syscallbuf_timeslice2
sysconf
sysctl
sysemu_singlestep
sysinfo
tcgets
tgkill
thread_stress
timer
timerfd
times
tiocgwinsz
truncate
tty_ioctls
uname
unjoined_thread
unshare
utimes
vfork_flush
video_capture
wait
write_race
writev
xattr
zero_length_read
)
# A "test with program" consists of a foo.c source file and a foo.run driver
# script. See src/test/util.sh to learn how the .run files work.
#
# NB: you must update this variable when adding a new test source
# file. The list is not generated automatically.
#
# Alphabetical, please.
set(TESTS_WITH_PROGRAM
abort_nonmain
args
async_kill_with_threads
async_kill_with_threads_main_running
async_kill_with_threads_thread_running
async_segv
async_signal_syscalls
async_signal_syscalls_siginfo
async_usr1
block_intr_sigchld
blocked_bad_ip
breakpoint
breakpoint_overlap
call_function
checkpoint_dying_threads
clone_interruption
conditional_breakpoint_calls
condvar_stress
crash
exit_group
exit_status
explicit_checkpoints
fork_syscalls
function_calls
getcwd
goto_event
hello
ignored_async_usr1
immediate_restart
interrupt
intr_ptrace_decline
link
main_thread_exit
mmap_shared_prot
mmap_write
mutex_pi_stress
nanosleep
priority
read_big_struct
restart_abnormal_exit
reverse_continue_breakpoint
segfault
stack_growth
step_thread
string_instructions
string_instructions_replay
syscallbuf_fd_disabling
target_fork
target_process
term_nonmain
threaded_syscall_spam
threads
tiocinq
unexpected_stack_growth
user_ignore_sig
vfork
watchpoint
watchpoint_syscall
watchpoint_unaligned
)
# A "test without program" is a foo.run driver script only, which does
# something with one of the test executables above (or has special rules
# to build its own executable).
#
# NB: you must update this variable when adding a new test source
# file. The list is not generated automatically.
#
# Alphabetical, please.
set(TESTS_WITHOUT_PROGRAM
async_signal_syscalls_100
async_signal_syscalls_1000
bad_breakpoint
break_block
break_clock
break_clone
break_exec
break_int3
break_mmap_private
break_msg
break_rdtsc
break_sigreturn
break_sync_signal
break_thread
break_time_slice
breakpoint_consistent
call_exit
checkpoint_async_signal_syscalls_1000
checkpoint_mmap_shared
checkpoint_prctl_name
checkpoint_simple
cont_signal
cpuid
dead_thread_target
deliver_async_signal_during_syscalls
env_newline
execp
explicit_checkpoint_clone
fork_exec_info_thr
get_thread_list
hardlink_mmapped_files
parent_no_break_child_bkpt
parent_no_stop_child_crash
read_bad_mem
remove_watchpoint
restart_unstable
restart_diversion
reverse_alarm
reverse_finish
reverse_step_breakpoint
reverse_step_signal
reverse_watchpoint
reverse_watchpoint_syscall
sanity
shm_checkpoint
signal_stop
signal_checkpoint
simple_script
simple_script_debug
simple_winch
step1
step_rdtsc
step_signal
string_instructions_replay_quirk
subprocess_exit_ends_session
syscallbuf_timeslice_250
trace_version
term_trace_cpu
term_trace_syscall
when
)
foreach(test ${BASIC_TESTS} ${TESTS_WITH_PROGRAM})
add_executable(${test} src/test/${test}.c)
add_dependencies(${test} Generated)
target_link_libraries(${test} -lrt)
endforeach(test)
add_library(test_lib
src/test/test_lib.c
)
add_dependencies(test_lib Generated)
target_link_libraries(constructor -lrt test_lib)
# cpuid test needs to link with cpuid_loop.S
add_executable(cpuid src/test/cpuid.c src/test/cpuid_loop.S)
add_dependencies(cpuid Generated)
target_link_libraries(cpuid -lrt)
foreach(test ${BASIC_TESTS} ${OTHER_TESTS})
add_test(${test}
bash ${CMAKE_SOURCE_DIR}/src/test/basic_test.run -b ${CMAKE_SOURCE_DIR} ${PROJECT_BINARY_DIR} ${test})
set_tests_properties(${test}
PROPERTIES FAIL_REGULAR_EXPRESSION "FAILED")
add_test(${test}-no-syscallbuf
bash ${CMAKE_SOURCE_DIR}/src/test/basic_test.run -n ${CMAKE_SOURCE_DIR} ${PROJECT_BINARY_DIR} ${test})
set_tests_properties(${test}-no-syscallbuf
PROPERTIES FAIL_REGULAR_EXPRESSION "FAILED")
endforeach(test)
foreach(test ${TESTS_WITH_PROGRAM} ${TESTS_WITHOUT_PROGRAM})
add_test(${test}
bash ${CMAKE_SOURCE_DIR}/src/test/${test}.run -b ${CMAKE_SOURCE_DIR} ${PROJECT_BINARY_DIR} ${test})
set_tests_properties(${test}
PROPERTIES FAIL_REGULAR_EXPRESSION "FAILED")
add_test(${test}-no-syscallbuf
bash ${CMAKE_SOURCE_DIR}/src/test/${test}.run -n ${CMAKE_SOURCE_DIR} ${PROJECT_BINARY_DIR} ${test})
set_tests_properties(${test}-no-syscallbuf
PROPERTIES FAIL_REGULAR_EXPRESSION "FAILED")
endforeach(test)
# Run 32-bit tests on 64-bit builds.
# We copy the test files into '32' subdirectories in the output
# directory, so we can set different compile options on them.
# This sucks but I can't find a better way to get CMake to build
# the same source file in two different ways.
if(rr_64BIT)
set_source_files_properties(32/rrutil.h
PROPERTIES GENERATED true HEADER_FILE_ONLY true)
add_custom_command(OUTPUT 32/rrutil.h
COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/32 &&
mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/bin/32 &&
cp -f "${CMAKE_CURRENT_SOURCE_DIR}/src/test/rrutil.h"
"${CMAKE_CURRENT_BINARY_DIR}/32/rrutil.h"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/test/rrutil.h")
foreach(test ${BASIC_TESTS} ${TESTS_WITH_PROGRAM} cpuid test_lib)
set_source_files_properties(32/${test}.c
PROPERTIES GENERATED true COMPILE_FLAGS -m32)
add_custom_command(OUTPUT 32/${test}.c
COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/32 &&
cp "${CMAKE_CURRENT_SOURCE_DIR}/src/test/${test}.c"
"${CMAKE_CURRENT_BINARY_DIR}/32/${test}.c"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/test/${test}.c" 32/rrutil.h)
endforeach(test)
foreach(file cpuid_loop.S)
set_source_files_properties(32/${file}
PROPERTIES GENERATED true COMPILE_FLAGS -m32)
add_custom_command(OUTPUT 32/${file}
COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/32 &&
cp "${CMAKE_CURRENT_SOURCE_DIR}/src/test/${file}"
"${CMAKE_CURRENT_BINARY_DIR}/32/${file}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/test/${file}")
endforeach(file)
foreach(test ${BASIC_TESTS} ${TESTS_WITH_PROGRAM})
add_executable(${test}_32 32/${test}.c)
add_dependencies(${test}_32 Generated)
set_target_properties(${test}_32 PROPERTIES LINK_FLAGS -m32)
target_link_libraries(${test}_32 -lrt)
endforeach(test)
add_library(test_lib_32
32/test_lib.c
)
add_dependencies(test_lib_32 Generated)
set_target_properties(test_lib_32 PROPERTIES LINK_FLAGS -m32)
target_link_libraries(constructor_32 -lrt test_lib_32)
# cpuid test needs to link with cpuid_loop.S
add_executable(cpuid_32 32/cpuid.c 32/cpuid_loop.S)
add_dependencies(cpuid_32 Generated)
set_target_properties(cpuid_32 PROPERTIES LINK_FLAGS -m32)
target_link_libraries(cpuid_32 -lrt)
foreach(test ${BASIC_TESTS} ${OTHER_TESTS})
add_test(${test}-32
bash ${CMAKE_SOURCE_DIR}/src/test/basic_test.run -b ${CMAKE_SOURCE_DIR} ${PROJECT_BINARY_DIR} ${test}_32)
set_tests_properties(${test}-32
PROPERTIES FAIL_REGULAR_EXPRESSION "FAILED")
add_test(${test}-32-no-syscallbuf
bash ${CMAKE_SOURCE_DIR}/src/test/basic_test.run -n ${CMAKE_SOURCE_DIR} ${PROJECT_BINARY_DIR} ${test}_32)
set_tests_properties(${test}-32-no-syscallbuf
PROPERTIES FAIL_REGULAR_EXPRESSION "FAILED")
endforeach(test)
foreach(test ${TESTS_WITH_PROGRAM} ${TESTS_WITHOUT_PROGRAM})
add_test(${test}-32
bash ${CMAKE_SOURCE_DIR}/src/test/${test}.run -b ${CMAKE_SOURCE_DIR} ${PROJECT_BINARY_DIR} ${test}_32)
set_tests_properties(${test}-32
PROPERTIES FAIL_REGULAR_EXPRESSION "FAILED")
add_test(${test}-32-no-syscallbuf
bash ${CMAKE_SOURCE_DIR}/src/test/${test}.run -n ${CMAKE_SOURCE_DIR} ${PROJECT_BINARY_DIR} ${test}_32)
set_tests_properties(${test}-32-no-syscallbuf
PROPERTIES FAIL_REGULAR_EXPRESSION "FAILED")
endforeach(test)
endif()
include(ProcessorCount)
ProcessorCount(N)
if(NOT N EQUAL 0)
set(JFLAG -j${N})
endif()
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --verbose ${JFLAG})
# Run only syscallbuf-enabled and native-bitness tests
add_custom_target(fastcheck COMMAND ${CMAKE_CTEST_COMMAND} --verbose --exclude-regex '[-]' ${JFLAG})
##--------------------------------------------------
## Package configuration
include (InstallRequiredSystemLibraries)
set(CPACK_PACKAGE_NAME "rr")
set(CPACK_PACKAGE_VERSION_MAJOR "${rr_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${rr_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${rr_VERSION_PATCH}")
set(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
set(CPACK_OUTPUT_FILE_PREFIX dist)
set(CPACK_GENERATOR "TGZ;RPM;DEB")
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_BINARY_DIR "${PROJECT_BINARY_DIR}")
set(CPACK_STRIP_FILES TRUE)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
"Lightweight tool for recording and replaying execution of applications (trees of processes and threads)")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md")
set(CPACK_PACKAGE_VENDOR "Mozilla Foundation")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Mozilla Foundation")
set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "i.86")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "i386")
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm.*")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "arm")
endif()
# XXX Cmake 2.8.7 doesn't know how to avoid specifiying /usr,
# /usr/bin, etc, as files to be installed, but distros are finicky
# about their specification. We want to manually filter those paths
# out of our install list but 2.8.7 also isn't capable of that.
set(CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_SOURCE_DIR}/rr.spec")
set(CPACK_RPM_PACKAGE_RELEASE 1)
set(CPACK_RPM_PACKAGE_GROUP "Development/Debuggers")
set(CPACK_RPM_PACKAGE_LICENSE "MIT and BSD")
include (CPack)
##--------------------------------------------------
## Misc
add_custom_target(setup-travis COMMAND src/script/setup_travis.sh)