List:Commits« Previous MessageNext Message »
From:Magnus Svensson Date:February 19 2008 4:15pm
Subject:Re: [Fwd: bk commit into 5.1 tree (hezx:1.2675)] versional test
View as plain text  
He Zhenxing wrote:
> Hi Magnus
> 
> Thank you for your nice review! See below.
> 
> 
> The following is actually what I want, but it doesn't work.
> 
> if (!$have_${_engine_type})
> {
>   skip requires '$_engine_type' storage engine;
> }
> 
> I would be very glad to rewrite this, any suggestion would be
> appreciated.
> 

Ok, I checked this today and as you write, there is really no way of 
declaring variables with dynamic variable names.

My suggestion would be to declare all the variables you need to 
initalize in supported_engines.inc, something like:
let $have_innodb= `select (support = 'YES' or support = 'DEFAULT' or 
support = 'ENABLED') as `TRUE` from information_schema.engines where 
engine = 'innodb'`;
let $have_federated= `select (support = 'YES' or support = 'DEFAULT' or 
support = 'ENABLED') as `TRUE` from information_schema.engines where 
engine = 'federated'`;
... and so on

The engines shouldn't change that often and when we add a new it's just 
to add it at the end of that file.

Besides, maybe you should write supported_engines.inc like
--source include/check_innodb.inc
--source include/check_federated.inc
...

That way we can include either a file the check only _one_  engine(like 
we do today) or check all supported engines in one go.

The include/check_innodb.inc would then do:
let $have_innodb= `select (support = 'YES' or support = 'DEFAULT' or 
support = 'ENABLED') as `TRUE` from information_schema.engines where 
engine = 'innodb'`;

And then include/have_innodb.inc would do:
--source include/check_innodb.inc
if ($have_innodb){
   skip Test need InnoDB;
}



>>> diff -Nrup a/mysql-test/include/supported_engines.inc
> b/mysql-test/include/supported_engines.inc
>>> --- /dev/null	Wed Dec 31 16:00:00 196900
>>> +++ b/mysql-test/include/supported_engines.inc	2008-01-17 16:23:50 +08:00
>>> @@ -0,0 +1,5 @@
>>> +disable_query_log;
>>> +--exec $MYSQL -e 'show engines' | sed -ne "s/^\([^
> 	]\+\)\s\+\(YES\|DEFAULT\).*/--let \$have_\1=1/p" >
> $MYSQLTEST_VARDIR/tmp/supported_engines.inc
>>
>> magnus: sed is not portable. Can you descibe what you need and I'll try 
>> to help with a way to extract it.
>>

If we _really_ _really_ need this, you should use something like

SELECT concat(concat("let \$have_", engine), "=1;") FROM 
information_schema.engines WHERE support='YES' OR support='DEFAULT'
INTO OUTFILE $MYSQLTEST_VARDIR/tmp/supported_engines.inc;

and then source that file. ;)

> 
> What I want is to have a workable way to check supported engines for all
> versions. 
> 
> The sed regexpr examines each line ofthe output of show engines,
> extracts the first column as the <ENGINE_TYPE>, and check if the second
> column is YES or DEFAULT, then substitute this line to:
>   --let have_<ENGINE_TYPE>=1
> otherwise, the line is omitted.
> 
>> As it is now, I don't really see what the let $have_<engine> variables 
>> are used for.
>>
> 
> The above code will define a variable have_<ENGINE_TYPE>=1 if the engine
> <ENGINE_TYPE> is supported, i.e. have_MyISAM=1, have_CSV=1, etc. if the
> engines is not supported, no variable is defined.
> 
> It is used in include/have_engine.inc, and may be used directly in test
> case to check if given engine or engines avaiable by:
> if ($have_<ENGINE_TYPE>)
> {
>   # do test that need <ENGINE_TYPE>
> }

I hope the above suggestion would do for now.

In general I would say that we should not depend so much on if we have a 
certain engine, but rather if the current engine supports a specific 
feature.



Thus feature1.test would be written like:

--source include/check_support_blobs.inc

if ($current_engine_supports_blob)
{
  Test with blobs;
}

--source include/check_support_auto_increment.inc

if ($current_engine_supports_auto_increment)
{
  Test with auto_increment;
}


You see how I mean?

Then we can run feature1.test for all engines, that is already supported 
by mysql-test-run.pl

Best regards
Magnus
Thread
[Fwd: bk commit into 5.1 tree (hezx:1.2675)] versional testHe Zhenxing29 Jan
  • Re: [Fwd: bk commit into 5.1 tree (hezx:1.2675)] versional testMagnus Svensson4 Feb
    • Re: [Fwd: bk commit into 5.1 tree (hezx:1.2675)] versional testHe Zhenxing13 Feb
      • Re: [Fwd: bk commit into 5.1 tree (hezx:1.2675)] versional testMagnus Svensson19 Feb
        • Re: [Fwd: bk commit into 5.1 tree (hezx:1.2675)] versional testHe Zhenxing20 Feb
          • Re: [Fwd: bk commit into 5.1 tree (hezx:1.2675)] versional testMagnus Svensson22 Feb