From a88dd3007379dd5dc726b05e26a29b670759e623 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sat, 19 Mar 2011 01:11:15 -0700 Subject: [PATCH] Start of magic sniffing tests. --- lib/go/camli/magic/magic_test.go | 41 +++++++++++++++++++++++++ lib/go/camli/magic/testdata/foo.tar | Bin 0 -> 10240 bytes lib/go/camli/magic/testdata/foo.tar.gz | Bin 0 -> 163 bytes lib/go/camli/magic/testdata/foo.zip | Bin 0 -> 300 bytes lib/go/camli/magic/testdata/smile.bmp | Bin 0 -> 7654 bytes lib/go/camli/magic/testdata/smile.gif | Bin 0 -> 927 bytes lib/go/camli/magic/testdata/smile.ico | Bin 0 -> 4086 bytes lib/go/camli/magic/testdata/smile.jpg | Bin 0 -> 1198 bytes lib/go/camli/magic/testdata/smile.png | Bin 0 -> 1221 bytes lib/go/camli/magic/testdata/smile.psd | Bin 0 -> 5236 bytes lib/go/camli/magic/testdata/smile.tiff | Bin 0 -> 1502 bytes lib/go/camli/magic/testdata/smile.xcf | Bin 0 -> 2951 bytes 12 files changed, 41 insertions(+) create mode 100644 lib/go/camli/magic/magic_test.go create mode 100644 lib/go/camli/magic/testdata/foo.tar create mode 100644 lib/go/camli/magic/testdata/foo.tar.gz create mode 100644 lib/go/camli/magic/testdata/foo.zip create mode 100644 lib/go/camli/magic/testdata/smile.bmp create mode 100644 lib/go/camli/magic/testdata/smile.gif create mode 100644 lib/go/camli/magic/testdata/smile.ico create mode 100644 lib/go/camli/magic/testdata/smile.jpg create mode 100644 lib/go/camli/magic/testdata/smile.png create mode 100644 lib/go/camli/magic/testdata/smile.psd create mode 100644 lib/go/camli/magic/testdata/smile.tiff create mode 100644 lib/go/camli/magic/testdata/smile.xcf diff --git a/lib/go/camli/magic/magic_test.go b/lib/go/camli/magic/magic_test.go new file mode 100644 index 000000000..933f4ef09 --- /dev/null +++ b/lib/go/camli/magic/magic_test.go @@ -0,0 +1,41 @@ +/* +Copyright 2011 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +nYou may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package magic + +import ( + . "camli/test/asserts" + "io/ioutil" + "testing" +) + +type magicTest struct { + fileName, expected string +} + +var tests = []magicTest{ + {"smile.jpg", "image/jpeg"}, + {"smile.png", "image/png"}, +} + +func TestGolden(t *testing.T) { + for _, test := range tests { + data, err := ioutil.ReadFile("testdata/" + test.fileName) + AssertNil(t, err, "no error reading " + test.fileName) + mime := MimeType(data) + ExpectString(t, test.expected, mime, test.fileName) + } +} diff --git a/lib/go/camli/magic/testdata/foo.tar b/lib/go/camli/magic/testdata/foo.tar new file mode 100644 index 0000000000000000000000000000000000000000..495006e342199c75919fe42d2519ade95e4ae49b GIT binary patch literal 10240 zcmeIvJr2S!42EIPoFX^CE^cz3RuIHOrBW77Pl`~P%0!S5uebcjPM$9h!&WMnmP)OP zTGCzPqG}ectY0N&t(!(`Vk-AEr6i%P{H{m)>t*W35TqZweLhXMwV8+WaqZ}r_jAd= z@5ZWMm}8FqE`MM0cb)HRYz9$O+ literal 0 HcmV?d00001 diff --git a/lib/go/camli/magic/testdata/foo.tar.gz b/lib/go/camli/magic/testdata/foo.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..f735f229923a728ed8e41d0b60e79f0809e04199 GIT binary patch literal 163 zcmb2|=3r1wZt-PcetXf8>yUv!>%%p+u6Yl9=Bhl;yx1Yly)n;b@5(9fN)(sq{n;OT zsJZgPCyRHn$w5mM{7g+*F>Mitr?KPk8{Fb M&hDPhpuxZZ07F|%^8f$< literal 0 HcmV?d00001 diff --git a/lib/go/camli/magic/testdata/foo.zip b/lib/go/camli/magic/testdata/foo.zip new file mode 100644 index 0000000000000000000000000000000000000000..9ee5fe500acf789b5090b8fa70778a0146fafe7f GIT binary patch literal 300 zcmWIWW@h1H009|}VmmMcO0Y1xYJLGB9sXYVmyx#HAJ742&#SJ}@w_bOb&3GP3r7$W;v80pb4W0WodISN1H*zwkS{?d Wft`lSFjh8@g-k#=9Z1)MI1B(vTQ5HV literal 0 HcmV?d00001 diff --git a/lib/go/camli/magic/testdata/smile.bmp b/lib/go/camli/magic/testdata/smile.bmp new file mode 100644 index 0000000000000000000000000000000000000000..ef4ac5d2cffea0de5ae7d28e61d625e12e71d72c GIT binary patch literal 7654 zcmeI0Jxe296o3=IHHuH+^lQ&ffdAG4-e7ofNn(Kk0Yk!Pwn zVUoNmS|%5ocv@SiNF;*KRRvB^YP*TKyu3{6%OZ;5| zY6^OxEZ72biD@nyt*oqM>BNe})z;P~i%<=g!d9CaP1bY#k>(<~EbAWbv(*%ABM5-V z{$N=mnrSXIxo8O%!ATo|BYZNNQ8mRa$%XGUmj`lWVPT=BrexM(I9WBunBO3aIB?(XiAQCvnG=jP_*v>O{6ON-|1Zg8EP zoUk{6#zlc@-gwf64X%%mkJHoB|BQ?gm%htUDVna5?+NuIHcj7w>-k{r&8@ zd`y_1pMQCIv2#&Io1VY!?(TR8H2128hK7TK1O2Zw%x=rOA18ZAGcc5j1{ce4Pfw4$ zA(WMsadc30**EO$?8sxyGVjOl@9*{lj8+Yn+S+m%sF7cc<}hP4=TU+V*mgE literal 0 HcmV?d00001 diff --git a/lib/go/camli/magic/testdata/smile.gif b/lib/go/camli/magic/testdata/smile.gif new file mode 100644 index 0000000000000000000000000000000000000000..7467497921ffdcaa5171f436921e6326f662d891 GIT binary patch literal 927 zcmZ?wbhEHbG-5DfIF`%+1dNP~OiWD7%*-q-EUc`oY;0`o?CcyI9Gsk-TwGk-+}u1o zJiNTT{QUd^0s=xpLc+qrA|fJUVq)Ur;t~=PQc_YfGBUEVvhwos3JMB}ii%1~O3KR0 zDk>_fs;cVh>KYmvnwpw=dU^&121Z6k#>U1bCMITPX6EMR78VwEc6Rpm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ic/testdata/smile.png new file mode 100644 index 0000000000000000000000000000000000000000..0de7d14d974407933a1da2b46842c754a8b72f19 GIT binary patch literal 1221 zcmV;$1UmbPP)Px#32;bRa{vGf6951U69E94oEQKA00(qQO+^RW0}}`cEJZVOz5oCK8FWQhbVF}# zZDnqB07G(RVRU6=Aa`kWXdp*PO;A^X4i^9b1TslPK~z}7?O07nGF=p&t7HCU4JH|b z!3-58Z6r-U9TC@mpwzd-56tt0AyJ!^%)+PyS6~RD3ix{JzO+s9upOuT6 z83L)8Z{bJTI6CubzHjjLEXRAC=bq=BJI}d56h-9cL4*8A{L=cR^*^J9s$ZJR<@WaW zj*gD<`Mk|$o0ymg27?4aG=dgTd2VGgnT3UgY&KiE-r;a05($c;s>cd~z_RSg$w@w+ z@9*#T`FzTo5!J!(_X7aR!zqfY9+=H$$H&Jtnt!VW!?4xWRmIn-qQ$bTPN%DFW5Hlh zDi8pZlap6hS9Q^X5V~BhN}Lq4rPu3aN(X@D<>k6)ZEtU*sC;MG?RJJ?6y&IYk&%%q zQ5rQ3`1bZz{=BoZb9Z-FvEF4X5!Uz^S5SS;r8cof5}R;%oDpU+oU zCqf8&dwWYmnwpxD$)w5_URha@Rsa6}zTQqeJw5e$y~PT%*=(^`jN>?!v>qNFNRlk& zgke}Zo&JUcqE4jKX_w2T)9Fkm)9mc*_4T!42>5lUzqA@?Y#tvU4-O6v4-XLpnVOpN z`~5hM|7BjHD8}P)9LE6w0011vpBuSD)L{VH{Uze;<^aURXg+dmKr5NS$ zc#8J52Jk#j)AXkcDjG_(@ArUMPw}2ph_YWm&V?ERipjN`0|` z<>j@xx!F+p+-|qzjWkUcn+7TEi00O literal 0 HcmV?d00001 diff --git a/lib/go/camli/magic/testdata/smile.psd b/lib/go/camli/magic/testdata/smile.psd new file mode 100644 index 0000000000000000000000000000000000000000..6be6eb8a365d3203b8282f4068061a0e3ae1efd8 GIT binary patch literal 5236 zcmeHK%}Z2K6hHTU%#5Q`lOHoS7>#{kwg^$NS(ONhl7e6mwGq*niBeM#gf<3kBEg+l zt3a5g3;%()XlqyyF5Fy6jSBo|o-^Z&GoF5T#s>QXYGLnP-n;kx&N;txKhAykyhul1 zKM5*cI;!Tv?IG1x*Y!w8cdx!(X#1%PwLm$pmCPuJNK=)!7k77wPeDb#0-Iit;0ay5 zTiK3|O^mS8B8n6%*mn#LJ&8_?O^yze(s?>L`WUiW++OOSK^meb6r~9oqe&X2VR+O2 zC>0c-8mgjds>HJfB|zmR4KG-{bRH!L&Jdl0p35E#mKx&0TsRCkf=S)uC+TDuzxzmNfygyhSE&^InqSe zrvpy0kWHC_9=Q)mh=~IB&d8DoT4{#pmO^M6zy)|9ktOOXDhaTZ$8CUB0B4JA4d{w1 zzR&a=bivI7cy+yRGpPDi0-f5bhuFWA=5;ognoRHg&#BVLT)Z{k(=)%d$}XM@2@#rG zWsUENBcj`@EVvh@K6{_dtg7Jivmuw9?UDox29Op7(71jba3 zb1aswWXY`uueA-l{b*-Y=!~}oOe}Ms%<&=XiN!{dB#-V1UcOpiS81jc5xn`#N+fxkD-tVj z1|p3Y&w7Fnt;F7O05}`T*+|YtayAmaYR-w|oJjx8iBw7ri)rLvNgw}(kCO@N3OgyP alcJuw6x9iF=P&G(|Ajdr?u7U$5Ak1cSLFu) literal 0 HcmV?d00001 diff --git a/lib/go/camli/magic/testdata/smile.tiff b/lib/go/camli/magic/testdata/smile.tiff new file mode 100644 index 0000000000000000000000000000000000000000..cb23fc1caacd14427baf379fb68d7a8a69c980d7 GIT binary patch literal 1502 zcmebD)MA*#!objA|Gf$|a$$>kbsAH9ThqdHV&Z|{%4-#)CGNXV%9%6c zh48z)=WFKY0s8PN*goJ%8O+$%xLPItW&`2D|F||qy;W}?l}3e+dOG%HeRD( z=gRDJ-FD%N6|3zxYcAWyw)f06ej+hX()8|)6Oh5GYrnDi;mlIEYkBdy% zc6kRYk63`hiZv=u=Ux=Yy;ogq8uMf-``nbKwy7(9qg%F~S+il@M1xoUH+UC*4qD*- za+_$Rpp=;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xcf new file mode 100644 index 0000000000000000000000000000000000000000..3e0914f1e6c723bd30403e9085c8b55dabef4b33 GIT binary patch literal 2951 zcmeHI&2Jl35P#3!P5hA%H)&(AQo7+owUJV#Nfmm6sED?RMv4Ry0tr>FvtF<8M`F9e z6^En}7eu6TssbmZN;&3`f4~Q>L4e?t%e#<&z$=ls_1ob$n{{zT_zUop#&7mFGrxH| zGtcX|m36CCC|X6gYzwS~P*^_)krF>skl2mygkZrs4>2GS$aJW)-v#*J!anYRcCJvX zRP1UK&w`DU@73*m(_XW_bekpX)(0!AY)J*KZYA&7b57k|V+`I>WE;%~W!q}h%I;b& zku5rfTDexYvcWc2ckbn_`786mIzzb{nsNxecSdO6ZvD5yp{>SxzTj3J>uNt2zz1i6 zAvSlv>NYL6S}55Kj;|Gq4ZHdLfE@jA=oEP|lKx!2dQ5B4W{BVYK!sn_mTgR*fq zc#S}~I|PY^IyWF5>exhLKu-?nV*~p5fIb18x%z7q3g_T8I1Q(Whk`0}DL;QN(CjXY@xym_n!9AQ%S2b(rMN<2^Y67{?i7aZ31 zX+kUDiioFiBF|(thc1O2T9)Xa96(zUrpzfu19n5vMf4@faD0yd}W+ zUYm|Z!PGU