3

We have to ssh into our school's server to make sure our programming assignments work on the system that will be used to test them by the teacher. It's running RHEL 6.2. When I test my program on my Mac running RHEL 6.2 in VirtualBox, I get different results than the school's. Are there any steps I can take to get my RHEL running similarly enough to the school's so that we get the same results, or are there too many variables for it to be plausible (hardware, root settings, etc)?

EDIT: The programming is in C++ for an Operating Systems class. We're working with system calls and whatnot. It's using tcsh, g++...other than that I'm not sure what else you'd need to know? This is my first unix/linux class.

Marty
  • 897
  • 2
    What programming is this? The results shouldn't be different for most kinds of programming even in Windoze! [I am assuming C/C++ type programming and not bash/csh] –  Feb 12 '12 at 04:40
  • 1
    While you could attempt to clone an entire school machine into a virtual machine, it would probably easier to set up a similar development and runtime environment. You already said that you have the same OS, but you've left out other important details like what sort of programming you are doing as well as what language you are using and what version of the compiler or interpreter the school uses. – jw013 Feb 12 '12 at 04:45
  • 7
    Too general to say anything. Please give a specific example of different results. – Faheem Mitha Feb 12 '12 at 05:31
  • 2
    It would be nice to give some examples of the "different results" you see. For starters, make sure you are using the same compiler versions and flags on both systems. – jw013 Feb 12 '12 at 05:42
  • The different results are just that the program, when run on my system, would crash at one point (I think it was at a fgets() call) , and when run on the school's, would get past this point, and crash at a different one (fdopen() I believe). Obviously in both cases, the code has bugs, I just want it as close to the same as possible so I don't get it working on mine, and then have it not work on the school's. – Marty Feb 12 '12 at 06:02
  • 2
    Behavior like that is going to be difficult to get consistent. It sounds like issues from uninitialized variables upon which the behavior is quite random. It all depends on what was last using the address space your variable now occupies, so matching the EXACT library versions between your machine and the school's is going to be as close as you can get, but you will likely never get it identical. – phemmer Feb 12 '12 at 06:38
  • It's not easy to get consistently portable bugs, since usually bugs invoke quite a bit of "undefined" or "unspecified" behavior meaning the implementation can fail however it likes. Use gdb to help debug. If you still can't find your bugs, start cleaning up (reorganize, comment, and prune) your code until you do find it. – jw013 Feb 12 '12 at 07:30
  • well schucks. okay thanks. if someone wants to put an answer that has a few things I'd want to make sure are the same on both machines, I'll accept it. – Marty Feb 12 '12 at 07:30

2 Answers2

6

You are attempting to do the opposite of what you should be doing. If your desire is to find and fix bugs, so that you don't submit programs with bugs, you should use two environments that are as different as possible. That way, if one platform doesn't fail due to a bug, there's a chance you'll be able to catch the bug on the other platform.

Your goal should be to write working software, not software that happens to work when you tried it.

  • hmm good point. i agree. but ultimately, my goal is to pass the class. so if it works on the school's computer and not mine, i wouldn't be too concerned. but that is a good point.

    Murphys huh? I have family there.

    – Marty Feb 12 '12 at 07:56
  • 3
    If your code has bugs, there's a good chance you'll get marked down because of it, even if it "happens to work". Worse, the code may work when you try it and then fail when others try it. You don't want to submit code with unknown bugs. Plus, by not finding and fixing any bugs you write, you'll persist in writing code with those bugs, you'll learn slower, and your grades will likely suffer eventually. (Yep, Murphys. Near scenic Angels Camp.) – David Schwartz Feb 12 '12 at 08:05
0

If you want an environment as close as possible to the one at school, ask them what they run and the configuration they use for automated (re)installation of lab machines (you'll probably need to tweak it extensively, so it doesn't assume centrally handled authentication or $HOME mounted over the network, and leave out closed software to which you don't have a license). If they use RHEL and can't allow you to use the same, go for a clone like CentOS (aims at binary compatibility).

vonbrand
  • 18,253