18c2ecf20Sopenharmony_ciTest the nx-gzip function:
28c2ecf20Sopenharmony_ci=========================
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ciVerify that following device exists:
58c2ecf20Sopenharmony_ci  /dev/crypto/nx-gzip
68c2ecf20Sopenharmony_ciIf you get a permission error run as sudo or set the device permissions:
78c2ecf20Sopenharmony_ci   sudo chmod go+rw /dev/crypto/nx-gzip
88c2ecf20Sopenharmony_ciHowever, chmod may not survive across boots. You may create a udev file such
98c2ecf20Sopenharmony_cias:
108c2ecf20Sopenharmony_ci   /etc/udev/rules.d/99-nx-gzip.rules
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ciTo manually build and run:
148c2ecf20Sopenharmony_ci$ gcc -O3 -I./include -o gzfht_test gzfht_test.c gzip_vas.c
158c2ecf20Sopenharmony_ci$ gcc -O3 -I./include -o gunz_test gunz_test.c gzip_vas.c
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ciCompress any file using Fixed Huffman mode. Output will have a .nx.gz suffix:
198c2ecf20Sopenharmony_ci$ ./gzfht_test gzip_vas.c
208c2ecf20Sopenharmony_cifile gzip_vas.c read, 6413 bytes
218c2ecf20Sopenharmony_cicompressed 6413 to 3124 bytes total, crc32 checksum = abd15e8a
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ciUncompress the previous output. Output will have a .nx.gunzip suffix:
258c2ecf20Sopenharmony_ci./gunz_test gzip_vas.c.nx.gz
268c2ecf20Sopenharmony_cigzHeader FLG 0
278c2ecf20Sopenharmony_ci00 00 00 00 04 03
288c2ecf20Sopenharmony_cigzHeader MTIME, XFL, OS ignored
298c2ecf20Sopenharmony_cicomputed checksum abd15e8a isize 0000190d
308c2ecf20Sopenharmony_cistored   checksum abd15e8a isize 0000190d
318c2ecf20Sopenharmony_cidecomp is complete: fclose
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ciCompare two files:
358c2ecf20Sopenharmony_ci$ sha1sum gzip_vas.c.nx.gz.nx.gunzip gzip_vas.c
368c2ecf20Sopenharmony_cibf43e3c0c3651f5f22b6f9784cd9b1eeab4120b6  gzip_vas.c.nx.gz.nx.gunzip
378c2ecf20Sopenharmony_cibf43e3c0c3651f5f22b6f9784cd9b1eeab4120b6  gzip_vas.c
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ciNote that the code here are intended for testing the nx-gzip hardware function.
418c2ecf20Sopenharmony_ciThey are not intended for demonstrating performance or compression ratio.
428c2ecf20Sopenharmony_ciBy being simplistic these selftests expect to allocate the entire set of source
438c2ecf20Sopenharmony_ciand target pages in the memory so it needs enough memory to work.
448c2ecf20Sopenharmony_ciFor more information and source code consider using:
458c2ecf20Sopenharmony_cihttps://github.com/libnxz/power-gzip
46