[FFmpeg-devel] [PATCH] remove unused and broken test program in libavutil/base64.c

Michael Niedermayer michaelni
Sun Feb 1 23:33:08 CET 2009


On Sun, Feb 01, 2009 at 07:06:21PM +0100, Stefano Sabatini wrote:
> On date Saturday 2009-01-31 22:08:26 +0100, Michael Niedermayer encoded:
> > On Sat, Jan 31, 2009 at 07:08:41PM +0100, Stefano Sabatini wrote:
> > > On date Saturday 2009-01-31 01:11:00 +0100, Michael Niedermayer encoded:
> > > > On Sat, Jan 31, 2009 at 12:26:20AM +0100, Stefano Sabatini wrote:
> > > > > On date Friday 2009-01-30 17:06:22 +0100, Michael Niedermayer encoded:
> > > > > > On Fri, Jan 30, 2009 at 12:46:36AM +0100, Stefano Sabatini wrote:
> > > > > [...]
> > > > > > > I think I addressed all the points.
> > > > > > > 
> > > > > > > Round 5:
> > > > > > > ------------------8<----------------------8<-------------------------
> > > > > > > #ifdef TEST
> > > > > > > #include "mem.h"
> > > > > > > #include "lfg.h"
> > > > > > > 
> > > > > > > #undef printf
> > > > > > > 
> > > > > > > #define MAX_DATA_SIZE    1024
> > > > > > > #define MAX_ENCODED_SIZE 2048
> > > > > > > 
> > > > > > 
> > > > > > > #define SHOW_STUFF(stuff) show_stuff ? (const char *)stuff : "[...]"
> > > > > > 
> > > > > > please explain wat this is supposed to be good for?
> > > > > 
> > > > > Yes, here there is the first lines of the output:
> > > > > 
> > > > > Encoding/decoding tests
> > > > > Encoding data with size 0 bytes ''... encoded as ''... passed!
> > > > > Encoding data with size 1 bytes '1'... encoded as 'MQ=='... passed!
> > > > > Encoding data with size 2 bytes '22'... encoded as 'MjI='... passed!
> > > > > Encoding data with size 3 bytes '333'... encoded as 'MzMz'... passed!
> > > > > Encoding data with size 4 bytes '4444'... encoded as 'NDQ0NA=='... passed!
> > > > > Encoding data with size 5 bytes '55555'... encoded as 'NTU1NTU='... passed!
> > > > > Encoding data with size 6 bytes '666666'... encoded as 'NjY2NjY2'... passed!
> > > > > Encoding data with size 7 bytes 'abc:def'... encoded as 'YWJjOmRlZg=='... passed!
> > > > > Encoding data with size 0 bytes '[...]'... encoded as '[...]'... passed!
> > > > > Encoding data with size 968 bytes '[...]'... encoded as '[...]'... passed!
> > > > > Encoding data with size 780 bytes '[...]'... encoded as '[...]'... passed!
> > > > > Encoding data with size 647 bytes '[...]'... encoded as '[...]'... passed!
> > > > > ...
> > > > > 
> > > > > For the data with a reference encoded string I think it is a good idea
> > > > > to show how the data is encoded, in case of problem the hacker should
> > > > > be able to immediately spot where the problem is.
> > > > > 
> > > > > For the other ones the length of the encoded string is usually too
> > > > > long and it is too awkward to display it, but no strong opinion on
> > > > > this, just tell how do you prefer it.
> > > > 
> > > > hmm ok, ive not conciously registererd that this was run with several hundread
> > > > bytes.
> > > > >  
> > > > > > [...]
> > > > > > >     printf("\nDecoding tests on invalid data\n");
> > > > > > >     {
> > > > > > >         uint8_t data[32];
> > > > > > >         const char *encoded[] = { "M", "M=M=", "MQ===" };
> > > > > > 
> > > > > > why is this splited off and not in the main table?
> > > > > 
> > > > > I believe this test cannot be reduced to the previous one, here we're
> > > > > just *decoding* and checking for validity.
> > > > 
> > > > if(A) A -> decode, cmp B
> > > > if(B) B -> encode, cmp A
> > > >
> > > > B being NULL
> > > >
> > > > am i missing something? 
> > > 
> > > The test is an encoding/decoding test, not a decoding/encoding test,
> > > we could maybe find some trick to make encode_decode_test() act as a
> > > decoding invalidity test, but this:
> > > 
> > > 1) would increase complexity of a program meant to be simple
> > > 2) it's not worth the trouble
> > 
> > a if(B) is hardly more complex than to duplicate the whole check
> 
> Well we have:
> test_encode_decode:
> D -> E, cmp (E, E'), E -> D', cmp (D, D')
> 
> the second test is:
> E -> D, if decode successfull -> fail

if(D){
    D->E'
    if(cmp(E, E'))
        fail
}

E->D'
if(cmp(D, D'))
    fail

cmp(A,B){
    if((!A) != (!B)) return -1
    else if(A)       return strcmp(A,B)
}

anyway if this turns out more complex, forget it


> 
> I cannot see an immediate way to reduce the second test to the first
> one, if there is I think it would most likely make the code more
> complex, maybe I'm wrong.
> 
> > also about SHOW_STUFF() it shouldnt be there and you shouldnt print
> > anything at all if things are ok, just print what does not produce the
> > expected output or an OK at the end
> > if a 1kb case mismatches it should be printed as well
> 
> OK, done, but printing data will show non-printable chars, is this a
> problem?

well, of course, printing hex maybe better for debuging anyway.

also i think we are wasting time on this rather pointless piece of code
i guess thats my fault :(


>  
> > > > [...]
> > > > > -- 
> > > > > FFmpeg = Fostering and Fundamental Murdering Peaceful Educated Guru
> > > > 
> > > > are you aware that some of these are semantically contradictionary?
> > > 
> > > Yes, and FFmpeg itself has some internal contradictions ;-),
> > > furthermore semantic checkers are a little expensive these days...
> > 
> > really?
> > 
> > download some book in ascii txt format
> > grep for a word starting with f
> > then grep for "<1word> f" 
> > then grep for "<2word> m" 
> > then grep for "<3word> p" 
> > ...
> > 
> > the result should be less boring i hope :)
> > at least each consecutive word pair would be semantically valid even if
> > longer chains may not be
> 
> Well, I followed your suggestion (check the attached script),
> unfortunately is not easy to find such a words chain even in large
> books, for example check this:

hmm seems you are not completely wrong, i also dont end up with too
good ones

face from my part even Gandalf
face from my pity even Gandalf
fact, for my part even Gandalf
fact, for my pity even Gandalf
faded from my part even Gandalf
faded from my pity even Gandalf
failed, Frodo my part even Gandalf
failed, Frodo my pity even Gandalf
fail, Frodo my part even Gandalf
fail, Frodo my pity even Gandalf
fairer, for my part even Gandalf
fairer, for my pity even Gandalf
fallen from my part even Gandalf
fallen from my pity even Gandalf
fall. Farewell my part even Gandalf
fall. Farewell my pity even Gandalf
fall; for my part even Gandalf
fall; for my pity even Gandalf
fall from my part even Gandalf
fall from my pity even Gandalf
falling from my part even Gandalf
falling from my pity even Gandalf
famous for my part even Gandalf
famous for my pity even Gandalf
Faramir for my part even Gandalf
Faramir. 'For my part even Gandalf
Faramir for my pity even Gandalf
Faramir. 'For my pity even Gandalf
Faramir from my part even Gandalf
Faramir from my pity even Gandalf
Farewell for my part even Gandalf
Farewell for my pity even Gandalf
far from my part even Gandalf
far from my pity even Gandalf
fast for my part even Gandalf
fast for my pity even Gandalf
father, for my part even Gandalf
father, for my pity even Gandalf
fear; for my part even Gandalf
fear for my part even Gandalf
fear. For my part even Gandalf
fear; for my pity even Gandalf
fear for my pity even Gandalf
fear. For my pity even Gandalf
fear from my part even Gandalf
fear from my pity even Gandalf
feel from my part even Gandalf
feel from my pity even Gandalf
fell from my part even Gandalf
fell from my pity even Gandalf
fellows from my part even Gandalf
fellows from my pity even Gandalf
field, for my part even Gandalf
field; for my part even Gandalf
field, for my pity even Gandalf
field; for my pity even Gandalf
fifth, Frodo my part even Gandalf
fifth, Frodo my pity even Gandalf
find Faramir must part even Gandalf
fingered Frodo my part even Gandalf
fingered Frodo my pity even Gandalf
finished, Frodo my part even Gandalf
finished, Frodo my pity even Gandalf
fire from my part even Gandalf
fire from my pity even Gandalf
first. For my part even Gandalf
first. For my pity even Gandalf
first, from my part even Gandalf
first, from my pity even Gandalf
fit for my part even Gandalf
fit for my pity even Gandalf
fits; for my part even Gandalf
fits; for my pity even Gandalf
fitted Frodo my part even Gandalf
fitted Frodo my pity even Gandalf
fitting for my part even Gandalf
fitting for my pity even Gandalf
flank; for my part even Gandalf
flank; for my pity even Gandalf
flee from my part even Gandalf
flee from my pity even Gandalf
fleet from my part even Gandalf
fleet from my pity even Gandalf
flickered from my part even Gandalf
flickered from my pity even Gandalf
flitting from my part even Gandalf
flitting from my pity even Gandalf
floated from my part even Gandalf
floated from my pity even Gandalf
floor. From my part even Gandalf
floor. From my pity even Gandalf
flowed from my part even Gandalf
flowed from my pity even Gandalf
fluttered from my part even Gandalf
fluttered from my pity even Gandalf
flying from my part even Gandalf
flying from my pity even Gandalf
folk, for my part even Gandalf
folk, for my pity even Gandalf
...
(752 matches in tolkiens The Return of the King)

#!/bin/sh

read len
echo $[ len + 1 ]

if test "$len" == "1" ; then
    cat *03*.txt | tr '\n' ' ' | egrep -io "\b$1[a-zA-Z]*[^a-zA-Z]{1,}$2[a-zA-Z]*" |sort|uniq|tr ' ' '@'
    exit
fi

for i in `sort -t @ -k $len </dev/stdin` ; do
    word=`echo $i | grep -o '[a-zA-Z]*$'`
    echo "$i" | grep '^[0-9]' >/dev/null && continue
    if test "$word" != "$lastword" ; then
        cat *03*.txt | tr '\n' ' ' | egrep -io "\b$word[^a-zA-Z]{1,}$1[a-zA-Z]*" | grep -o '[a-zA-Z]*$'|sort|uniq >tmp$len
    fi
    sed "s/^/$i@/" <tmp$len
    lastword=$word
done

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Opposition brings concord. Out of discord comes the fairest harmony.
-- Heraclitus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090201/a1d81ff4/attachment.pgp>



More information about the ffmpeg-devel mailing list