1#!/bin/ksh -p
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22
23#
24# Copyright (c) 2022 by Attila Fülöp <attila@fueloep.org>
25#
26
27. $STF_SUITE/include/libtest.shlib
28
29#
30# DESCRIPTION:
31#       Make sure we have SIMD support, so it will not go away without notice
32#
33# STRATEGY:
34#	1. Test if we are running on a Linux x86 system with SSE support
35#       2. If so, check if the zfs_fletcher_4_impl module parameter contains
36#	   a sse implementation
37#	3. If not fail the test, otherwise pass it
38
39log_note "Testing if we support SIMD instructions (Linux x86 only)"
40
41if !is_linux; then
42    log_unsupported "Not a Linux System"
43fi
44
45case "$(uname -m)" in
46i386|i686|x86_64)
47	typeset -R modparam="/sys/module/zcommon/parameters/zfs_fletcher_4_impl"
48	if cat /proc/cpuinfo | awk '/^flags/ {print; exit;}' | grep -q sse; then
49		log_must grep -q sse "$modparam"
50		log_pass "SIMD instructions supported"
51	else
52		log_unsupported "No FPU present"
53	fi
54	;;
55*)
56	log_unsupported "Not a x86 CPU"
57	;;
58esac
59