gdb: split regcaches management selftest
authorSimon Marchi <simon.marchi@polymtl.ca>
Thu, 20 Aug 2020 14:10:59 +0000 (10:10 -0400)
committerSimon Marchi <simon.marchi@polymtl.ca>
Thu, 20 Aug 2020 14:10:59 +0000 (10:10 -0400)
commitcdd9148a19e9c0acb99ef0908671f60ea9ad69bc
tree576e6765bd810f70f7fc62ce3d560a67eb48c357
parentdd125343a1cccac2878d528d61a5ea71e46793fa
gdb: split regcaches management selftest

The selftest `regcaches` selftest is a bit too broad for my taste,
testing the behavior of get_thread_arch_aspace_regcache and various
cases of registers_changed_ptid.  Since I'll want to test even more
scenarios of registers_changed_ptid, passing different sets of
parameters, it will be difficult to do in a single test case.  It is
difficult to change something at some point in the test case while make
sure it doesn't compromise what comes after, that we still test the
scenarios that we intended to test.  So, split the test case in multiple
smaller ones.

- Split the test case in multiple, where each test case starts from
  scratch and tests one specific scenario.

- Introduce the populate_regcaches_for_test function, which is used by
  the various test cases to start with a regcache container populated
  with a few regcaches for two different targets.

- populate_regcaches_for_test returns a regcache_test_data object, which
  contains the test targets that were used to create the regcaches.  It
  also takes care to call registers_changed at the beginning and end of
  the test to ensure the test isn't influenced by existing regcaches,
  and cleans up after itself.

- Move the regcache_count lambda function out of
  regcache_thread_ptid_changed, so it can be used in
  other tests.

- For get_thread_arch_aspace_regcache, test that getting a regcache that
  already exists does not increase the count of existing regcaches.

- For registers_changed_ptid, test the three cases we handle today:
  (nullptr, minus_one_ptid), (target, minus_one_ptid) and (target,
  ptid).  The (target, minus_one_ptid) case was not tested prior to this
  patch.

gdb/ChangeLog:

* regcache.c (regcache_count): New.
(struct regcache_test_data): New.
(regcache_test_data_up): New.
(populate_regcaches_for_test): New.
(regcaches_test): Remove.
(get_thread_arch_aspace_regcache_test): New.
(registers_changed_ptid_all_test): New.
(registers_changed_ptid_target_test): New.
(registers_changed_ptid_target_ptid_test): New.
(regcache_thread_ptid_changed): Remove regcache_count lambda.
(_initialize_regcache): Register new tests.

Change-Id: Id4280879fb40ff3aeae49b01b95359e1359c3d4b
gdb/ChangeLog
gdb/regcache.c
This page took 0.024088 seconds and 4 git commands to generate.