summaryrefslogtreecommitdiffstats
path: root/desktop/modules/perf/test_vram.sh
blob: 7ef4adea96b26824f1ed7bfff801327f9c909b61 (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
#!/bin/sh
#
# Copyright (C) 2026 Danilo M. <danix@danix.xyz>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# vram.sh: summed once per xe client id, units honoured, other drivers
# ignored; nothing at all when no xe client is found.
set -e
dir=$(dirname "$0")
tmp=$(mktemp)
trap 'rm -f "$tmp"' EXIT

printf '%s\n' \
    "/proc/1/fdinfo/7:drm-driver:	xe" \
    "/proc/1/fdinfo/7:drm-client-id:	38" \
    "/proc/1/fdinfo/7:drm-resident-vram0:	1024 KiB" \
    "/proc/1/fdinfo/10:drm-driver:	xe" \
    "/proc/1/fdinfo/10:drm-client-id:	38" \
    "/proc/1/fdinfo/10:drm-resident-vram0:	1024 KiB" \
    "/proc/2/fdinfo/5:drm-driver:	xe" \
    "/proc/2/fdinfo/5:drm-client-id:	40" \
    "/proc/2/fdinfo/5:drm-resident-vram0:	2 MiB" \
    "/proc/3/fdinfo/4:drm-driver:	amdgpu" \
    "/proc/3/fdinfo/4:drm-client-id:	1" \
    "/proc/3/fdinfo/4:drm-resident-vram0:	9 GiB" > "$tmp"
got=$(sh "$dir/vram.sh" "$tmp")
[ "$got" = $((1024 * 1024 + 2 * 1024 * 1024)) ] || { echo "vram: got '$got'"; exit 1; }

: > "$tmp"
got=$(sh "$dir/vram.sh" "$tmp")
[ -z "$got" ] || { echo "empty: got '$got'"; exit 1; }
echo ok