xref: /OK3568_Linux_fs/kernel/tools/testing/selftests/powerpc/nx-gzip/README (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunTest the nx-gzip function:
2*4882a593Smuzhiyun=========================
3*4882a593Smuzhiyun
4*4882a593SmuzhiyunVerify that following device exists:
5*4882a593Smuzhiyun  /dev/crypto/nx-gzip
6*4882a593SmuzhiyunIf you get a permission error run as sudo or set the device permissions:
7*4882a593Smuzhiyun   sudo chmod go+rw /dev/crypto/nx-gzip
8*4882a593SmuzhiyunHowever, chmod may not survive across boots. You may create a udev file such
9*4882a593Smuzhiyunas:
10*4882a593Smuzhiyun   /etc/udev/rules.d/99-nx-gzip.rules
11*4882a593Smuzhiyun
12*4882a593Smuzhiyun
13*4882a593SmuzhiyunTo manually build and run:
14*4882a593Smuzhiyun$ gcc -O3 -I./include -o gzfht_test gzfht_test.c gzip_vas.c
15*4882a593Smuzhiyun$ gcc -O3 -I./include -o gunz_test gunz_test.c gzip_vas.c
16*4882a593Smuzhiyun
17*4882a593Smuzhiyun
18*4882a593SmuzhiyunCompress any file using Fixed Huffman mode. Output will have a .nx.gz suffix:
19*4882a593Smuzhiyun$ ./gzfht_test gzip_vas.c
20*4882a593Smuzhiyunfile gzip_vas.c read, 6413 bytes
21*4882a593Smuzhiyuncompressed 6413 to 3124 bytes total, crc32 checksum = abd15e8a
22*4882a593Smuzhiyun
23*4882a593Smuzhiyun
24*4882a593SmuzhiyunUncompress the previous output. Output will have a .nx.gunzip suffix:
25*4882a593Smuzhiyun./gunz_test gzip_vas.c.nx.gz
26*4882a593SmuzhiyungzHeader FLG 0
27*4882a593Smuzhiyun00 00 00 00 04 03
28*4882a593SmuzhiyungzHeader MTIME, XFL, OS ignored
29*4882a593Smuzhiyuncomputed checksum abd15e8a isize 0000190d
30*4882a593Smuzhiyunstored   checksum abd15e8a isize 0000190d
31*4882a593Smuzhiyundecomp is complete: fclose
32*4882a593Smuzhiyun
33*4882a593Smuzhiyun
34*4882a593SmuzhiyunCompare two files:
35*4882a593Smuzhiyun$ sha1sum gzip_vas.c.nx.gz.nx.gunzip gzip_vas.c
36*4882a593Smuzhiyunbf43e3c0c3651f5f22b6f9784cd9b1eeab4120b6  gzip_vas.c.nx.gz.nx.gunzip
37*4882a593Smuzhiyunbf43e3c0c3651f5f22b6f9784cd9b1eeab4120b6  gzip_vas.c
38*4882a593Smuzhiyun
39*4882a593Smuzhiyun
40*4882a593SmuzhiyunNote that the code here are intended for testing the nx-gzip hardware function.
41*4882a593SmuzhiyunThey are not intended for demonstrating performance or compression ratio.
42*4882a593SmuzhiyunBy being simplistic these selftests expect to allocate the entire set of source
43*4882a593Smuzhiyunand target pages in the memory so it needs enough memory to work.
44*4882a593SmuzhiyunFor more information and source code consider using:
45*4882a593Smuzhiyunhttps://github.com/libnxz/power-gzip
46