This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC 2/7] Add unit test to builtin tdesc generated by xml

Pedro Alves <> writes:

>> +{
>> +  std::string feature_dir (ldirname (__FILE__));
>> +  struct stat st;
> Ugh.  Obviously this can't work if gdb is installed / copied elsewhere,
> remote host testing, etc.

I thought about this, but I can't figure out one better than __FILE__.
What I want to do is to find srcdir, and open these xml files during
unit tests.  Since it is a unit test, I expect gdb is executed in either
builddir/gdb or builddir/gdb/testsuite.  I don't see a case that people
build gdb in one place, and run unit/self tests somewhere else.

>> +
>> +  /* Look for the features directory.  If the directory of __FILE__ can't
>> +     be found, __FILE__ is a file name with relative path.  Guess that
>> +     GDB is executed in testsuite directory like ../gdb, because I don't
>> +     expect that GDB is invoked somewhere else and run self tests.  */
>> +  if (stat ( (), &st) < 0)
>> +    {
>> +      feature_dir.insert (0, SLASH_STRING);
>> +      feature_dir.insert (0, "..");
>> +
>> +      /* If still can't find the path, something is wrong.  */
>> +      SELF_CHECK (stat ( (), &st) == 0);
> Do we want to flag this as an error / unit test failure?
> Maybe it should be a warning instead?

We can skip this test if it can't find "features" directory in source, but
something wrong can be easily ignored if we do so.

>> --- a/gdb/target-descriptions.h
>> +++ b/gdb/target-descriptions.h
>> @@ -162,6 +162,12 @@ enum gdb_osabi tdesc_osabi (const struct target_desc *);
>>  int tdesc_compatible_p (const struct target_desc *,
>>  			const struct bfd_arch_info *);
>> +/* Compare target descriptions TDESC1 and TDESC2, return true if they
>> +   are identical.  */
>> +
>> +bool tdesc_equals (const struct target_desc *tdesc1,
>> +		   const struct target_desc *tdesc2);
> Any reason this and the other equals functions aren't operator==
> implementations?

tdesc_reg, tdesc_type, tdesc_feature and target_desc should be
class-fied first, including adding proper ctor, dtor, etc.  I thought it
must be a lot of work, so I don't do that.  I can do that if it doesn't
take me much time.

> It's not obvious since the comments say "identical", which would maybe
> suggest that
> there may be some property that is not being compared and thus this is not
> strict value equality, but then function name says "equals".

I think "identical" implies "strict value equality".  The information I
want to deliver is that this function compares all properties, return
true if they are exactly the same.  Is it this better,

/* Return true if target description TDESC1 and TDESC2 are equal.  */

Yao (齐尧)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]