END_TEST /* --------------------------------------------------------------------------------------------- */ START_TEST (test_vfs_parse_ls_lga_reorder) { size_t filepos = 0; struct vfs_s_entry *ent1, *ent2, *ent3; int i; vfs_parse_ls_lga_init(); ent1 = vfs_s_generate_entry (&vfs_test_ops1, NULL, vfs_root_inode, 0); i = ent1->ino->st.st_nlink; if (! vfs_parse_ls_lga ("drwxrwxr-x 10 500 500 4096 Jun 23 17:09 build_root1", &ent1->ino->st, &ent1->name, &ent1->ino->linkname, &filepos)) { fail ("An error occured while parse ls output"); return; } vfs_s_store_filename_leading_spaces (ent1, filepos); vfs_s_insert_entry (&vfs_test_ops1, vfs_root_inode, ent1); ent2 = vfs_s_generate_entry (&vfs_test_ops1, NULL, vfs_root_inode, 0); i = ent2->ino->st.st_nlink; if (! vfs_parse_ls_lga ("drwxrwxr-x 10 500 500 4096 Jun 23 17:09 build_root2", &ent2->ino->st, &ent2->name, &ent2->ino->linkname, &filepos)) { fail ("An error occured while parse ls output"); return; } vfs_s_store_filename_leading_spaces (ent2, filepos); vfs_s_insert_entry (&vfs_test_ops1, vfs_root_inode, ent2); ent3 = vfs_s_generate_entry (&vfs_test_ops1, NULL, vfs_root_inode, 0); i = ent3->ino->st.st_nlink; if (! vfs_parse_ls_lga ("drwxrwxr-x 10 500 500 4096 Jun 23 17:09 ..", &ent3->ino->st, &ent3->name, &ent3->ino->linkname, &filepos)) { fail ("An error occured while parse ls output"); return; } vfs_s_store_filename_leading_spaces (ent3, filepos); vfs_s_insert_entry (&vfs_test_ops1, vfs_root_inode, ent3); vfs_s_normalize_filename_leading_spaces (vfs_root_inode, vfs_parse_ls_lga_get_final_spaces ()); fail_unless(strcmp(ent1->name, " build_root1") == 0, "\nactual '%s'\nnot equal to '%s'\n", ent1->name, " build_root1"); fail_unless(strcmp(ent2->name, " build_root2") == 0, "\nactual '%s'\nnot equal to '%s'\n", ent2->name, " build_root2"); }
/* *INDENT-OFF* */ END_PARAMETRIZED_TEST /* *INDENT-ON* */ /* --------------------------------------------------------------------------------------------- */ /* @Test */ /* *INDENT-OFF* */ START_TEST (test_vfs_parse_ls_lga_reorder) /* *INDENT-ON* */ { /* given */ size_t filepos = 0; struct vfs_s_entry *ent1, *ent2, *ent3; vfs_parse_ls_lga_init (); /* init ent1 */ ent1 = vfs_s_generate_entry (&vfs_test_ops1, NULL, vfs_root_inode, 0); vfs_parse_ls_lga ("drwxrwxr-x 10 500 500 4096 Jun 23 17:09 build_root1", &ent1->ino->st, &ent1->name, &ent1->ino->linkname, &filepos); vfs_s_store_filename_leading_spaces (ent1, filepos); vfs_s_insert_entry (&vfs_test_ops1, vfs_root_inode, ent1); /* init ent2 */ ent2 = vfs_s_generate_entry (&vfs_test_ops1, NULL, vfs_root_inode, 0); vfs_parse_ls_lga ("drwxrwxr-x 10 500 500 4096 Jun 23 17:09 build_root2", &ent2->ino->st, &ent2->name, &ent2->ino->linkname, &filepos); vfs_s_store_filename_leading_spaces (ent2, filepos); vfs_s_insert_entry (&vfs_test_ops1, vfs_root_inode, ent2); /* init ent3 */ ent3 = vfs_s_generate_entry (&vfs_test_ops1, NULL, vfs_root_inode, 0); vfs_parse_ls_lga ("drwxrwxr-x 10 500 500 4096 Jun 23 17:09 ..", &ent3->ino->st, &ent3->name, &ent3->ino->linkname, &filepos); vfs_s_store_filename_leading_spaces (ent3, filepos); vfs_s_insert_entry (&vfs_test_ops1, vfs_root_inode, ent3); /* when */ vfs_s_normalize_filename_leading_spaces (vfs_root_inode, vfs_parse_ls_lga_get_final_spaces ()); /* then */ mctest_assert_str_eq (ent1->name, " build_root1"); mctest_assert_str_eq (ent2->name, " build_root2"); }