2 * This testing program makes sure the byteswap functions work
4 * Copyright (C) 2000 by Theodore Ts'o.
7 * This file may be redistributed under the terms of the GNU Public
20 #include <sys/types.h>
25 #if EXT2_FLAT_INCLUDES
28 #include <linux/ext2_fs.h>
43 0x00000001, 0x01000000,
44 0x80000000, 0x00000080,
45 0x12345678, 0x78563412,
46 0xffff0000, 0x0000ffff,
47 0x00ff0000, 0x0000ff00,
48 0xff000000, 0x000000ff,
49 0x00000000, 0x00000000
52 int main(int argc, char *argv)
57 printf("Testing ext2fs_swab16\n");
60 printf("swab16(0x%04x) = 0x%04x\n", test1[i],
61 ext2fs_swab16(test1[i]));
62 if (ext2fs_swab16(test1[i]) != test1[i+1]) {
63 printf("Error!!! %04x != %04x\n",
64 ext2fs_swab16(test1[i]), test1[i+1]);
67 if (ext2fs_swab16(test1[i+1]) != test1[i]) {
68 printf("Error!!! %04x != %04x\n",
69 ext2fs_swab16(test1[i+1]), test1[i]);
73 } while (test1[i] != 0);
75 printf("Testing ext2fs_swab32\n");
78 printf("swab32(0x%08x) = 0x%08x\n", test2[i],
79 ext2fs_swab32(test2[i]));
80 if (ext2fs_swab32(test2[i]) != test2[i+1]) {
81 printf("Error!!! %04x != %04x\n",
82 ext2fs_swab32(test2[i]), test2[i+1]);
85 if (ext2fs_swab32(test2[i+1]) != test2[i]) {
86 printf("Error!!! %04x != %04x\n",
87 ext2fs_swab32(test2[i+1]), test2[i]);
91 } while (test2[i] != 0);
94 printf("No errors found in the byteswap implementation!\n");