162306a36Sopenharmony_ciTest the nx-gzip function: 262306a36Sopenharmony_ci========================= 362306a36Sopenharmony_ci 462306a36Sopenharmony_ciVerify that following device exists: 562306a36Sopenharmony_ci /dev/crypto/nx-gzip 662306a36Sopenharmony_ciIf you get a permission error run as sudo or set the device permissions: 762306a36Sopenharmony_ci sudo chmod go+rw /dev/crypto/nx-gzip 862306a36Sopenharmony_ciHowever, chmod may not survive across boots. You may create a udev file such 962306a36Sopenharmony_cias: 1062306a36Sopenharmony_ci /etc/udev/rules.d/99-nx-gzip.rules 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ciTo manually build and run: 1462306a36Sopenharmony_ci$ gcc -O3 -I./include -o gzfht_test gzfht_test.c gzip_vas.c 1562306a36Sopenharmony_ci$ gcc -O3 -I./include -o gunz_test gunz_test.c gzip_vas.c 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ciCompress any file using Fixed Huffman mode. Output will have a .nx.gz suffix: 1962306a36Sopenharmony_ci$ ./gzfht_test gzip_vas.c 2062306a36Sopenharmony_cifile gzip_vas.c read, 6413 bytes 2162306a36Sopenharmony_cicompressed 6413 to 3124 bytes total, crc32 checksum = abd15e8a 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ciUncompress the previous output. Output will have a .nx.gunzip suffix: 2562306a36Sopenharmony_ci./gunz_test gzip_vas.c.nx.gz 2662306a36Sopenharmony_cigzHeader FLG 0 2762306a36Sopenharmony_ci00 00 00 00 04 03 2862306a36Sopenharmony_cigzHeader MTIME, XFL, OS ignored 2962306a36Sopenharmony_cicomputed checksum abd15e8a isize 0000190d 3062306a36Sopenharmony_cistored checksum abd15e8a isize 0000190d 3162306a36Sopenharmony_cidecomp is complete: fclose 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ciCompare two files: 3562306a36Sopenharmony_ci$ sha1sum gzip_vas.c.nx.gz.nx.gunzip gzip_vas.c 3662306a36Sopenharmony_cibf43e3c0c3651f5f22b6f9784cd9b1eeab4120b6 gzip_vas.c.nx.gz.nx.gunzip 3762306a36Sopenharmony_cibf43e3c0c3651f5f22b6f9784cd9b1eeab4120b6 gzip_vas.c 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ciNote that the code here are intended for testing the nx-gzip hardware function. 4162306a36Sopenharmony_ciThey are not intended for demonstrating performance or compression ratio. 4262306a36Sopenharmony_ciBy being simplistic these selftests expect to allocate the entire set of source 4362306a36Sopenharmony_ciand target pages in the memory so it needs enough memory to work. 4462306a36Sopenharmony_ciFor more information and source code consider using: 4562306a36Sopenharmony_cihttps://github.com/libnxz/power-gzip 46