aboutsummaryrefslogtreecommitdiff
path: root/benchmarks/linux-gputest
diff options
context:
space:
mode:
authorAlexey Dokuchaev <danfe@FreeBSD.org>2020-09-19 22:04:32 +0000
committerAlexey Dokuchaev <danfe@FreeBSD.org>2020-09-19 22:04:32 +0000
commit56d2983160374c5640fed81c17239beb2626a6e6 (patch)
tree107a24f57597759d9e5cea829303fe3aeaa89452 /benchmarks/linux-gputest
parentb5ec6d0d1b241cca03ab0f41285f0b5884bb819f (diff)
downloadports-56d2983160374c5640fed81c17239beb2626a6e6.tar.gz
ports-56d2983160374c5640fed81c17239beb2626a6e6.zip
To support optional FreeBSD branding in the future, switch to binary patch
instead of sed(1) when adjusting log file location. No functional changes.
Notes
Notes: svn path=/head/; revision=549074
Diffstat (limited to 'benchmarks/linux-gputest')
-rw-r--r--benchmarks/linux-gputest/Makefile11
-rw-r--r--benchmarks/linux-gputest/files/apply-binary-patch.pl33
-rw-r--r--benchmarks/linux-gputest/files/fix-logfile-path.crk95
3 files changed, 134 insertions, 5 deletions
diff --git a/benchmarks/linux-gputest/Makefile b/benchmarks/linux-gputest/Makefile
index 695d8fca24fd..23c5943f3a97 100644
--- a/benchmarks/linux-gputest/Makefile
+++ b/benchmarks/linux-gputest/Makefile
@@ -21,8 +21,11 @@ LICENSE_PERMS= dist-mirror pkg-mirror auto-accept
ONLY_FOR_ARCHS= amd64
-USES= linux zip
+PATCH_DEPENDS= p5-Sys-Mmap>0:devel/p5-Sys-Mmap
+
+USES= linux perl5 zip
USE_LINUX= dri libglvnd xorglibs
+USE_PERL5= patch
NO_BUILD= yes
OPTIONS_DEFINE= DOCS GUI
@@ -36,10 +39,8 @@ GUI_USES= python:run
post-patch:
@${REINPLACE_CMD} -e '1s,bash,sh,' ${WRKSRC}/start_*.sh
@${RM} ${WRKSRC}/data/.DS_Store
-# Save log file in writable location instead of ${PREFIX}/lib/${PORTNAME}
- @${REINPLACE_CMD} -e \
- 's,_geeks3d_gputest_log\.txt,/tmp/geeks3d_gputest.log,' \
- ${WRKSRC}/GpuTest
+ @cd ${WRKSRC} && ${PERL} ${FILESDIR}/apply-binary-patch.pl < \
+ ${FILESDIR}/fix-logfile-path.crk
# We cannot just embed shebang line in the patch because 210:fix-shebang
# happens before 500:do-patch :(
diff --git a/benchmarks/linux-gputest/files/apply-binary-patch.pl b/benchmarks/linux-gputest/files/apply-binary-patch.pl
new file mode 100644
index 000000000000..0f4315ee04d2
--- /dev/null
+++ b/benchmarks/linux-gputest/files/apply-binary-patch.pl
@@ -0,0 +1,33 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use Sys::Mmap;
+
+my $fh;
+my $flen;
+my $fdata;
+
+sub commit {
+ return unless $fh;
+ munmap $fdata or die "munmap: $!";
+ close $fh or die "close: $!";
+}
+
+while (<>) {
+ chomp;
+ if (/^([0-9A-F]{8}):? ([0-9A-F]{2}) ([0-9A-F]{2})$/i) {
+ my ($offset, $old, $new) = map hex, $1, $2, $3;
+ next unless $fdata;
+ next unless $offset < $flen;
+ next if ord substr($fdata, $offset, 1) != $old;
+ substr($fdata, $offset, 1) = chr $new;
+ } elsif (-e) {
+ commit;
+ open $fh, '+<', $_ or die "open: $!";
+ mmap $fdata, 0, PROT_READ | PROT_WRITE, MAP_SHARED, $fh
+ or die "mmap: $!";
+ $flen = -s;
+ }
+}
+commit;
diff --git a/benchmarks/linux-gputest/files/fix-logfile-path.crk b/benchmarks/linux-gputest/files/fix-logfile-path.crk
new file mode 100644
index 000000000000..6a6e1482a2f3
--- /dev/null
+++ b/benchmarks/linux-gputest/files/fix-logfile-path.crk
@@ -0,0 +1,95 @@
+; GpuTest is not cwd-agnostic and must be run in ${PREFIX}/lib/${PORTNAME}
+; where it looks for resources and writes its logfile. Change the logfile
+; location to user-writable directory (/tmp) and shift a couple of strings
+; to make the room for other changes.
+
+GpuTest
+
+00036FE0: 5F 2F
+00036FE1: 67 74
+00036FE2: 65 6D
+00036FE3: 65 70
+00036FE4: 6B 2F
+00036FE5: 73 5F
+00036FE6: 33 67
+00036FE7: 64 65
+00036FE8: 5F 65
+00036FE9: 67 6B
+00036FEA: 70 73
+00036FEB: 75 33
+00036FEC: 74 64
+00036FED: 65 5F
+00036FEE: 73 67
+00036FEF: 74 70
+00036FF0: 5F 75
+00036FF1: 6C 74
+00036FF2: 6F 65
+00036FF3: 67 73
+00036FF4: 2E 74
+00036FF5: 74 2E
+00036FF6: 78 6C
+00036FF7: 74 6F
+00036FF8: 00 67
+
+; "Linux x%d" moves +1 byte (1 reference)
+; 424bbb: be f9 6f 43 00 mov $0x436ff9,%esi
+00024BBC: F9 FA
+
+00036FF9: 4C 00
+00036FFA: 69 4C
+00036FFB: 6E 69
+00036FFC: 75 6E
+00036FFD: 78 75
+00036FFE: 20 78
+00036FFF: 78 20
+00037000: 25 78
+00037001: 64 25
+00037002: 00 64
+
+; "GpuTest" moves +3 bytes (3 references)
+; 424c4b: be 03 70 43 00 mov $0x437003,%esi
+; 424dba: b9 03 70 43 00 mov $0x437003,%ecx
+; 425040: ba 03 70 43 00 mov $0x437003,%edx
+00024C4C: 03 06
+00024DBB: 03 06
+00025041: 03 06
+
+00037003: 47 00
+00037004: 70 00
+00037005: 75 00
+00037006: 54 47
+00037007: 65 70
+00037008: 73 75
+00037009: 74 54
+0003700A: 00 65
+
+; "%s (%s) is starting up..." moves +3 bytes (1 reference)
+; 424d9c: ba 0b 70 43 00 mov $0x43700b,%edx
+00024D9D: 0B 0E
+
+0003700B: 25 73
+0003700C: 73 74
+0003700D: 20 00
+0003700E: 28 25
+0003700F: 25 73
+00037010: 73 20
+00037011: 29 28
+00037012: 20 25
+00037013: 69 73
+00037014: 73 29
+00037016: 73 69
+00037017: 74 73
+00037018: 61 20
+00037019: 72 73
+0003701B: 69 61
+0003701C: 6E 72
+0003701D: 67 74
+0003701E: 20 69
+0003701F: 75 6E
+00037020: 70 67
+00037021: 2E 20
+00037022: 2E 75
+00037023: 2E 70
+00037024: 00 2E
+00037025: 00 2E
+00037026: 00 2E