Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/agi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func (c *config) checkVM(java string, checkVersion bool) bool {

versionStr := string(version)

// Blacklist the Google custom JDKs.
// Don't use the Google custom JDKs as they don't work with our JNI libs.
if p := strings.Index(versionStr, googleInfix); p >= 0 {
c.logIfVerbose("Not using " + java + ": is a Google JDK (go/gapid-jdk)")
return false
Expand Down
60 changes: 30 additions & 30 deletions cmd/update-swt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// This is a very dumb script (see imDumb()) that tries to update the swt.bzl
// This is a very brittle script (see giveUp()) that tries to update the swt.bzl
// and jface.bzl files to upgrade SWT and JFace to a new Eclipse release
// version. To update to a newer version, visit
// https://download.eclipse.org/eclipse/downloads/, choose your version and
// click on it. The version to pass to this script is the last URL segment and
// should take the form "[RS]-<version>-<datetime>".
// This tool uses a bunch of regex's to parse HTML and the .bzl files, and does
// so in a dumb, but defensive manner. This means that trivial changes to the
// so in a rigid, but defensive manner. This means that trivial changes to the
// Eclipse HTML or the .bzl files will likely make the parsing fail, but at
// least if it succeeds, it's fairly confident that what it got is what it
// thinks it got.
Expand Down Expand Up @@ -107,8 +107,8 @@ func run(ctx context.Context) error {
return nil
}

func imDumb(ctx context.Context, cause error, fmt string, args ...interface{}) error {
log.E(ctx, "I'm a really dumb script and something may have changed. I give up.")
func giveUp(ctx context.Context, cause error, fmt string, args ...interface{}) error {
log.E(ctx, "My input parsing is very strict and some HTML may have changed. I give up.")
return log.Errf(ctx, cause, fmt, args...)
}

Expand All @@ -131,40 +131,40 @@ func getRepo(ctx context.Context, version string) (*repo, error) {

repoTable, err := extractTable(ctx, html, repoTableRegex)
if err != nil {
return nil, imDumb(ctx, err, "Failed to extract repository table")
return nil, giveUp(ctx, err, "Failed to extract repository table")
}
if len(repoTable) != 2 || len(repoTable[1]) != 1 {
return nil, imDumb(ctx, err, "Repo table has unexpected dimensions (%v)", repoTable)
return nil, giveUp(ctx, err, "Repo table has unexpected dimensions (%v)", repoTable)
}
base, err := extractLink(ctx, repoUrl, repoTable[1][0])
if err != nil {
return nil, imDumb(ctx, err, "Failed to extract repo URL")
return nil, giveUp(ctx, err, "Failed to extract repo URL")
}

r := &repo{base: base}

swtTable, err := extractTable(ctx, html, swtTableRegex)
if err != nil {
return nil, imDumb(ctx, err, "Failed to extract SWT table")
return nil, giveUp(ctx, err, "Failed to extract SWT table")
}
if len(swtTable) < 2 {
return nil, imDumb(ctx, err, "SWT table has not enough rows (%v)", swtTable)
return nil, giveUp(ctx, err, "SWT table has not enough rows (%v)", swtTable)
}
for _, row := range swtTable[1:] { // skip over the table headers
if len(row) != 3 {
return nil, imDumb(ctx, err, "SWT table has unexpected dimensions (%v)", swtTable)
return nil, giveUp(ctx, err, "SWT table has unexpected dimensions (%v)", swtTable)
}
link, err := extractLink(ctx, repoUrl, row[1])
if err != nil {
return nil, imDumb(ctx, err, "Failed to extract SWT URL")
return nil, giveUp(ctx, err, "Failed to extract SWT URL")
}
file := link.Query().Get("dropFile")
if file == "" {
return nil, imDumb(ctx, nil, "URL %v didn't contain a dropFile query parameter", link)
return nil, giveUp(ctx, nil, "URL %v didn't contain a dropFile query parameter", link)
}
link, err = link.Parse(file)
if err != nil {
return nil, imDumb(ctx, err, "Drop file '%s' caused an invalid URL", file)
return nil, giveUp(ctx, err, "Drop file '%s' caused an invalid URL", file)
}

switch row[0] {
Expand All @@ -181,7 +181,7 @@ func getRepo(ctx context.Context, version string) (*repo, error) {
}

if r.swtLinux == nil || r.swtWindows == nil || r.swtMacOS == nil {
return nil, imDumb(ctx, nil, "Didn't find SWT for every OS: %v %v %v", r.swtLinux, r.swtWindows, r.swtMacOS)
return nil, giveUp(ctx, nil, "Didn't find SWT for every OS: %v %v %v", r.swtLinux, r.swtWindows, r.swtMacOS)
}

return r, nil
Expand All @@ -206,11 +206,11 @@ func (r *repo) editSWTBazel(ctx context.Context) (err error) {

src, err := ioutil.ReadFile(swtBzl)
if err != nil {
return imDumb(ctx, err, "Failed to read swt.bzl at %s", swtBzl)
return giveUp(ctx, err, "Failed to read swt.bzl at %s", swtBzl)
}
matches := swtBzlRegex.FindAllSubmatchIndex(src, -1)
if len(matches) != 6 {
return imDumb(ctx, err, "Failed to match the swt.bzl regex (%b)", matches)
return giveUp(ctx, err, "Failed to match the swt.bzl regex (%b)", matches)
}

var b bytes.Buffer
Expand Down Expand Up @@ -238,11 +238,11 @@ func (r *repo) editSWTBazel(ctx context.Context) (err error) {

for os, d := range data {
if d.done != 3 {
return imDumb(ctx, nil, "Didn't find SHA/URL for OS %s (%d)", os, d.done)
return giveUp(ctx, nil, "Didn't find SHA/URL for OS %s (%d)", os, d.done)
}
}
if err := ioutil.WriteFile(swtBzl, b.Bytes(), 0644); err != nil {
return imDumb(ctx, err, "Failed to write output to swt.bzl")
return giveUp(ctx, err, "Failed to write output to swt.bzl")
}

log.I(ctx, "I've updated %s successfully... I think.", swtBzl)
Expand All @@ -257,29 +257,29 @@ func (r *repo) editJFaceBazel(ctx context.Context) error {
}
div, err := extractDiv(ctx, html, pluginsRegex)
if err != nil {
return imDumb(ctx, err, "Failed to extract plugins file list")
return giveUp(ctx, err, "Failed to extract plugins file list")
}
links, err := extractLinks(ctx, base, div)
if err != nil {
return imDumb(ctx, err, "Failed to extract plugins links")
return giveUp(ctx, err, "Failed to extract plugins links")
}
links = filterJars(links)

src, err := ioutil.ReadFile(jfaceBzl)
if err != nil {
return imDumb(ctx, err, "Failed to read jface.bzl at %s", jfaceBzl)
return giveUp(ctx, err, "Failed to read jface.bzl at %s", jfaceBzl)
}

matches := jfaceBaseRegex.FindAllIndex(src, -1)
if len(matches) != 1 {
return imDumb(ctx, err, "Failed to match the base JFace regex (%v)", matches)
return giveUp(ctx, err, "Failed to match the base JFace regex (%v)", matches)
}
src = append(src[:matches[0][0]],
append([]byte("_BASE = \""+base.String()+"\""), src[matches[0][1]:]...)...)

matches = jfaceBzlRegex.FindAllSubmatchIndex(src, -1)
if len(matches) == 0 {
return imDumb(ctx, nil, "Failed to match the JFace regex (%v)", matches)
return giveUp(ctx, nil, "Failed to match the JFace regex (%v)", matches)
}
if len(matches) != 8 {
log.W(ctx, "I found %d JFace jars, but I expected 8. Closing my eyes and continuing...", len(matches))
Expand All @@ -301,16 +301,16 @@ func (r *repo) editJFaceBazel(ctx context.Context) error {
}
}
if jar == nil || srcJar == nil {
return imDumb(ctx, nil, "Didn't find jar/src jar for %s", name)
return giveUp(ctx, nil, "Didn't find jar/src jar for %s", name)
}
version := jar.label[len(name)+1 : len(jar.label)-4]
jarSha, err := sha(ctx, jar.url.String())
if err != nil {
return imDumb(ctx, err, "Failed to get SHA for JAR %s", jar.label)
return giveUp(ctx, err, "Failed to get SHA for JAR %s", jar.label)
}
srcSha, err := sha(ctx, srcJar.url.String())
if err != nil {
return imDumb(ctx, err, "Failed to get SHA for src JAR %s", srcJar.label)
return giveUp(ctx, err, "Failed to get SHA for src JAR %s", srcJar.label)
}
fmt.Println(jarSha + " " + srcSha)
b.Write(src[loc[0]:loc[4]])
Expand All @@ -324,7 +324,7 @@ func (r *repo) editJFaceBazel(ctx context.Context) error {
b.Write(src[last:])

if err := ioutil.WriteFile(jfaceBzl, b.Bytes(), 0644); err != nil {
return imDumb(ctx, err, "Failed to write output to jface.bzl")
return giveUp(ctx, err, "Failed to write output to jface.bzl")
}

log.I(ctx, "I've updated %s successfully... I think.", jfaceBzl)
Expand All @@ -343,16 +343,16 @@ func fetch(ctx context.Context, url string) ([]byte, error) {
log.I(ctx, "Fetching %s...", url)
resp, err := http.Get(url)
if err != nil {
return nil, imDumb(ctx, err, "Failed to download '%s'", url)
return nil, giveUp(ctx, err, "Failed to download '%s'", url)
}
defer resp.Body.Close()

if resp.StatusCode < 200 || resp.StatusCode >= 300 {
return nil, imDumb(ctx, err, "Got a failure response (%d) from '%s'", resp.StatusCode, url)
return nil, giveUp(ctx, err, "Got a failure response (%d) from '%s'", resp.StatusCode, url)
}
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, imDumb(ctx, err, "Failed to read response from '%s'", url)
return nil, giveUp(ctx, err, "Failed to read response from '%s'", url)
}
return data, nil
}
Expand Down
22 changes: 11 additions & 11 deletions core/app/flags/repeated.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type repeated struct {
}

const (
dummyFlag = "dummy"
phFlag = "placeholder"
)

func newRepeatedFlag(value reflect.Value) flag.Value {
Expand All @@ -38,28 +38,28 @@ func newRepeatedFlag(value reflect.Value) flag.Value {
single := reflect.New(value.Type().Elem())
switch s := single.Interface().(type) {
case *bool:
fs.BoolVar(s, dummyFlag, *s, "")
fs.BoolVar(s, phFlag, *s, "")
case *int:
fs.IntVar(s, dummyFlag, *s, "")
fs.IntVar(s, phFlag, *s, "")
case *int64:
fs.Int64Var(s, dummyFlag, *s, "")
fs.Int64Var(s, phFlag, *s, "")
case *uint:
fs.UintVar(s, dummyFlag, *s, "")
fs.UintVar(s, phFlag, *s, "")
case *uint64:
fs.Uint64Var(s, dummyFlag, *s, "")
fs.Uint64Var(s, phFlag, *s, "")
case *float64:
fs.Float64Var(s, dummyFlag, *s, "")
fs.Float64Var(s, phFlag, *s, "")
case *string:
fs.StringVar(s, dummyFlag, *s, "")
fs.StringVar(s, phFlag, *s, "")
case *time.Duration:
fs.DurationVar(s, dummyFlag, *s, "")
fs.DurationVar(s, phFlag, *s, "")
case flag.Value:
fs.Var(s, dummyFlag, "")
fs.Var(s, phFlag, "")
default:
panic(fmt.Sprintf("Unhandled flag type: %v", single.Type()))
}

return &repeated{value, single, fs.Lookup(dummyFlag).Value}
return &repeated{value, single, fs.Lookup(phFlag).Value}
}

func (f *repeated) String() string {
Expand Down
4 changes: 2 additions & 2 deletions core/cc/linux/get_vulkan_proc_address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ struct MesaLLVMOpener {
void* getVulkanInstanceProcAddress(size_t instance, const char* name) {
typedef PFN_vkVoidFunction (*VPAPROC)(VkInstance instance, const char* name);

static MesaLLVMOpener _dummy;
(void)_dummy;
static MesaLLVMOpener _dlopenAllMesaVersions;
(void)_dlopenAllMesaVersions;

static DlLoader dylib("libvulkan.so", "libvulkan.so.1");

Expand Down
4 changes: 2 additions & 2 deletions core/data/dictionary/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ var (
vTy = generic.T2Ty
)

// Source is a dummy interface used to prototype a generic dictionary type.
// K and V can be subsituted with a different type.
// Source is a placeholder interface used to prototype a generic dictionary
// type. K and V can be subsituted with a different type.
type Source interface {
// Get returns the value of the entry with the given key.
Get(K) V
Expand Down
4 changes: 2 additions & 2 deletions core/git/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestParseLog(t *testing.T) {
ǁf3cdfb4d9b662e0d66b5779d02370115e136a008ǀBen ClaytonǀUpdate freetype path and fix for breaking changes.ǀ
ǁ92ee22e53df7b361224670cf0f5ce4b12cdbc040ǀBen Clayton <bclayton@google.com>ǀMerge pull request #154 from google/recreate_ctrlsǀAdd recreateControls flag to the OnDataChanged list/tree event.
ǁ73c5a5ba67edfd06d20f9f52249b06984a324d0cǀMr4xǀUpdated Grid Layoutǀ
ǁ1d039c122e95122e68e5862aab3580bba15bd1adǀMr4xǀMerge pull request #1 from google/masterǀUpdate`
ǁ1d039c122e95122e68e5862aab3580bba15bd1adǀMr4xǀMerge pull request #1 from google/fooǀUpdate`
expected := []ChangeList{
{
SHA: SHA{0xa5, 0xea, 0xeb, 0xbe, 0x90, 0xd6, 0x0b, 0x56, 0x0e, 0x08, 0xa6, 0x75, 0x09, 0x58, 0x75, 0x5a, 0x58, 0xe6, 0xf9, 0x99},
Expand All @@ -53,7 +53,7 @@ func TestParseLog(t *testing.T) {
{
SHA: SHA{0x1d, 0x03, 0x9c, 0x12, 0x2e, 0x95, 0x12, 0x2e, 0x68, 0xe5, 0x86, 0x2a, 0xab, 0x35, 0x80, 0xbb, 0xa1, 0x5b, 0xd1, 0xad},
Author: "Mr4x",
Subject: "Merge pull request #1 from google/master",
Subject: "Merge pull request #1 from google/foo",
Description: "Update",
},
}
Expand Down
2 changes: 1 addition & 1 deletion core/memory_tracker/cc/memory_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ class MemoryTrackerImpl : public SpecificMemoryTracker {
return result;
}

// Dummy function that we can pass down to the specific memory tracker.
// Placeholder function that we can pass down to the specific memory tracker.
bool DoHandleSegfault(void* v) { return HandleSegfault(v); }

// A helper function that returns the first tracking range that overlaps with
Expand Down
32 changes: 16 additions & 16 deletions core/memory_tracker/cc/memory_tracker_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class TestFixture : public ::testing::Test {
mutex_thread_init_order_.lock();
normal_thread_run_before_signal_handler_.lock();
m_.lock();
dummy_lock_.store(false, std::memory_order_seq_cst);
fake_lock_.store(false, std::memory_order_seq_cst);
deadlocked_.store(false, std::memory_order_seq_cst);
unique_test_ = this;
}
Expand All @@ -150,29 +150,29 @@ class TestFixture : public ::testing::Test {
thread_second.join();
}

// DoTask acquires the dummy lock and runs the given function.
// DoTask acquires the fake lock and runs the given function.
void DoTask(std::function<void(void)> task) {
DummyLock();
FakeLock();
normal_thread_run_before_signal_handler_
.unlock(); // This is to make sure the signal will only be send after
// the normal threads
task();
DummyUnlock();
FakeUnlock();
}

// RegisterHandlerAndTriggerSignal does the following things:
// 1) Registers a signal handler to SIGUSR1 which acquires the dummy lock.
// 2) Creates a child thread which will acquire the dummy lock.
// 1) Registers a signal handler to SIGUSR1 which acquires the fake lock.
// 2) Creates a child thread which will acquire the fake lock.
// 3) Waits for the child thread to run then sends a signal interrupt to the
// child thread.
// 4) Waits until the child thread finishes and clean up.
void RegisterHandlerAndTriggerSignal(void* (*child_thread_func)(void*)) {
auto handler_func = [](int, siginfo_t*, void*) {
// DummyLock is to simulate the case that the coherent memory tracker's
// FakeLock is to simulate the case that the coherent memory tracker's
// signal handler needs to access shared data.
unique_test_->DummyLock();
unique_test_->FakeLock();
;
unique_test_->DummyUnlock();
unique_test_->FakeUnlock();
};
struct sigaction orig_action;
ASSERT_TRUE(RegisterSignalHandler(SIGUSR1, handler_func, &orig_action));
Expand All @@ -186,16 +186,16 @@ class TestFixture : public ::testing::Test {
}

protected:
// Acquires the dummy lock. If the dummy lock has already been locked, i.e.
// Acquires the fake lock. If the fake lock has already been locked, i.e.
// its value is true, sets the deadlocked_ flag.
void DummyLock() {
if (dummy_lock_.load(std::memory_order_seq_cst)) {
void FakeLock() {
if (fake_lock_.load(std::memory_order_seq_cst)) {
deadlocked_.exchange(true);
}
dummy_lock_.exchange(true);
fake_lock_.exchange(true);
}
// Releases the dummy lock by setting its value to false.
void DummyUnlock() { dummy_lock_.exchange(false); }
// Releases the fake lock by setting its value to false.
void FakeUnlock() { fake_lock_.exchange(false); }

std::mutex normal_thread_run_before_signal_handler_; // A mutex to
// guarantee the normal
Expand All @@ -206,7 +206,7 @@ class TestFixture : public ::testing::Test {
// initiated before the other one
std::mutex m_; // A mutex for tuning execution order in tests
std::atomic<bool>
dummy_lock_; // An atomic bool to simulate the lock/unlock state
fake_lock_; // An atomic bool to simulate the lock/unlock state
std::atomic<bool> deadlocked_; // A flag to indicate deadlocked or not state

static TestFixture* unique_test_; // A static pointer of this test fixture,
Expand Down
6 changes: 3 additions & 3 deletions core/os/android/adb/forward.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ func (p TCPPort) adbForwardString() string {
// * The system _may_ hold on to the socket after it has been told to close.
// Because of these issues, there is a potential for flakiness.
func LocalFreeTCPPort() (TCPPort, error) {
dummy, err := net.Listen("tcp", ":0")
socket, err := net.Listen("tcp", ":0")
if err != nil {
return 0, err
}
defer dummy.Close()
return TCPPort(dummy.Addr().(*net.TCPAddr).Port), nil
defer socket.Close()
return TCPPort(socket.Addr().(*net.TCPAddr).Port), nil
}

// NamedAbstractSocket represents an abstract UNIX domain socket name on either
Expand Down
Loading