Unless there are any playing conditions that say otherwise or an agreement reached by the captains before the match, if play ends prematurely, due to bad weather perhaps, or ends with one side still batting but not having made enough runs to exceed the total opposition score, the match will end as a Draw.
Draws are not always dull affairs. Sometimes a draw will be regarded almost as a victory by one side, especially when teams are mis-matched, one being much better than the other. In such circumstances the weaker team will consider themselves to have played well if they can hold the stronger one to a draw.
In earlier times it was not unusual for the last Test Match in a series to be played to a finish - not limited by time or number of days. This produced some strange, usually very high scoring, matches. On Friday March 3, 1939, at the Kingsmead Ground in Durban, South Africa won the toss and chose to bat in the fifth and final Test of a series against England. They were all out by the afternoon of the third day, having posted a score of 530. England then batted and were dismissed during the fifth day for 316. By the end of the sixth day South Africa were all out for 481, having scored a mammoth 1011 runs in the match, setting England a target of 696 to win. By the end of the seventh day England had scored 253 of those runs for the loss of one wicket. No play was possible on the next - eighth day - because of heavy rain. By close of play on day nine England had managed to score 496 for the loss of just three wickets - and when rain brought proceedings to a halt on the afternoon of the tenth day, England, at 654 for 5, were just 42 runs away from what would have been an epic victory.
It was not to be. The Athlone Castle, the ship that was to carry the England team home, was due to depart from Cape Town the following day, so the match was declared a draw 'by agreement'. Including the two Sundays, on which no play took place in those days, it ran over twelve days in all, and has since become known as the 'Timeless Test'. Significantly it is the last occasion when a Test Match was scheduled to be played to a finish - even though it wasn't!