Add test case for /->: conversion from PR kern/44523 by

Taylor R Campbell.

I adjusted the test to uudecode + bunzip2 the supplied image, and
removed the "null-finder" from the dirent code, since it had an
off-by-one which made the test fail.
This commit is contained in:
pooka 2011-02-18 13:07:54 +00:00
parent 0e29006e71
commit 7e9c3f5ca7
4 changed files with 135 additions and 2 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.19 2010/08/01 08:32:17 pooka Exp $
# $NetBSD: Makefile,v 1.20 2011/02/18 13:07:54 pooka Exp $
.include <bsd.own.mk>
@ -6,7 +6,7 @@ TESTSDIR= ${TESTSBASE}/fs
SUBDIR+= common .WAIT
TESTS_SUBDIRS+= ffs kernfs lfs msdosfs nfs nullfs psshfs ptyfs puffs
TESTS_SUBDIRS+= ffs hfs kernfs lfs msdosfs nfs nullfs psshfs ptyfs puffs
TESTS_SUBDIRS+= tmpfs umapfs union
TESTS_SUBDIRS+= vfs

15
tests/fs/hfs/Makefile Normal file
View File

@ -0,0 +1,15 @@
# $NetBSD: Makefile,v 1.1 2011/02/18 13:07:54 pooka Exp $
#
TESTSDIR= ${TESTSBASE}/fs/hfs
TESTS_C= t_pathconvert
FILES= colon.hfs.bz2.uue
FILESDIR= ${TESTSDIR}
LDADD+= -lrumpfs_hfs # fs drivers
LDADD+= -lrumpdev_disk -lrumpdev # disk drivers
LDADD+= -lrumpvfs -lrump -lrumpuser -lpthread # base
.include <bsd.test.mk>

View File

@ -0,0 +1,35 @@
begin 644 colon.hfs.bz2
M0EIH.3%!629363%?)5P``$+____[_UOQ>_]__^_O\+____1K30045,CBA$'P
M'DA:2!KIT`3V\VRA*<ZPAUVK`E%-)E,IME3T33U--DFRCU,T33T@]-1HQ&1M
M(/2&@&TGI&@9#1B#0&F@TT:``R9/4$I$4PTF$Q,B8T)IY(VD:9&`3(80T>B&
M`$,"8C$P$T9!HR:81B,":`D20A3T:GI`9``#(>H-`:-```:`````````````
M08!#1B:`R:83)ID`&$:-,`F`)A!H9`Q,@#``"8F3`3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\,_CR;`,Y-E8*MM?Z*?BPU`I[I5^G-B$$A.
M\7&8DC*:*',@VKX0HL8O)DL<-9GG!8>NK.2XS2I.;Z3%Q9OIL8?(6-*DEGHW
MX^&A?%APXI:C@,A/&<6=)7#$UI;1Y6A'C<#/EW-*T(8WC9=`B`%\)M5HIS[\
MV1%+H,,()X19<,:)U:Y?V\-T!^]'A\%%%+Z6.PQ"QI$]3#11IRB<#.9-L)^!
MB-WJYVQVMP^;7V<DK?-[M;DQF]<[:M3)$-F@*(CXT128KESC.#OPP+`$D`G-
MA6$DKT2V\;3+*:U+2]66T]'1$A`=33.FMDA1G\MA$1V_"/+2]%!GTQI'8E03
M=?AO,S0#0V,9IS,&;8KGKL_$RKJFE62392;]B2933`4\$VJ""-0$;")-/A]R
M[D"*/0:F1=%1R!B9&8=^RD4B^;4O-6'*J4J)EVNWN[+!_$)1\;@+#>*W5MG'
MKUWYE^[,*T:U)Y]NUI,00H%8>74G/?LJ0K)51^BXZ+AI*2O[PI`V*%Q@X\YV
M!V?D08"^;*TYO4R)T6G5:M;_M5M*;H4V)1IKCL$01$`#1R%N5,'_B[DBG"A(
%&*^2K@"^
`
end

View File

@ -0,0 +1,83 @@
/* $NetBSD: t_pathconvert.c,v 1.1 2011/02/18 13:07:54 pooka Exp $ */
#include <sys/types.h>
#include <sys/mount.h>
#include <atf-c.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <rump/rump.h>
#include <rump/rump_syscalls.h>
#include <fs/hfs/hfs.h>
#include "../../h_macros.h"
ATF_TC(colonslash);
ATF_TC_HEAD(colonslash, tc)
{
atf_tc_set_md_var(tc, "descr", "HFS+ colons/slashes (PR kern/44523)");
atf_tc_set_md_var(tc, "timeout", "2");
}
#define IMGNAME "colon.hfs"
#define FAKEBLK "/dev/blk"
#define FUNNY_FILENAME "foo:bar"
ATF_TC_BODY(colonslash, tc)
{
struct hfs_args args;
int dirfd, fd;
char thecmd[1024];
char buf[DIRBLKSIZ];
struct dirent *dirent;
int offset, nbytes;
bool ok = false;
snprintf(thecmd, sizeof(thecmd), "uudecode %s/colon.hfs.bz2.uue",
atf_tc_get_config_var(tc, "srcdir"));
RZ(system(thecmd));
snprintf(thecmd, sizeof(thecmd), "bunzip2 " IMGNAME ".bz2");
RZ(system(thecmd));
memset(&args, 0, sizeof args);
args.fspec = __UNCONST(FAKEBLK);
RZ(rump_init());
RL(rump_sys_mkdir("/mp", 0777));
RZ(rump_pub_etfs_register(FAKEBLK, IMGNAME, RUMP_ETFS_BLK));
RL(rump_sys_mount(MOUNT_HFS, "/mp", 0, &args, sizeof args));
RL(dirfd = rump_sys_open("/mp", O_RDONLY));
RL(nbytes = rump_sys_getdents(dirfd, buf, sizeof buf));
for (offset = 0; offset < nbytes; offset += dirent->d_reclen) {
dirent = (struct dirent *)(buf + offset);
if (strchr(dirent->d_name, '/'))
atf_tc_fail("dirent with slash: %s", dirent->d_name);
if (0 == strcmp(FUNNY_FILENAME, dirent->d_name))
ok = true;
}
if (!ok)
atf_tc_fail("no dirent for file: %s", FUNNY_FILENAME);
RL(rump_sys_close(dirfd));
RL(fd = rump_sys_open("/mp/" FUNNY_FILENAME, O_RDONLY));
RL(rump_sys_close(fd));
RL(rump_sys_unmount("/mp", 0));
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, colonslash);
return 0;
}